-
Notifications
You must be signed in to change notification settings - Fork 284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added blpop and adjusted to signed 64 bit numbers #527
Conversation
Good point with the size, but should it be I don't like the The Regarding, What would possibly make sense for
But due to the additional cost caused be the heap closure, I'd suggest to make this an additional method instead of the only one. |
Ok so API calls are intentionally restricted to a response range & disallow individual values.
That would be rpush. The "shared" bool idea is ideal
"the returned integer is guaranteed to be in the range of a signed 64 bit integer."
It's not so bad use one-liners to secure an async api that might eventually implement responding through promises (with futures which wrap around the |
Oh okay... and I thought "lpush" meant "list push" all the time :)
But especially if there is a planned concept that will supersede such an API it makes no sense to introduce it now. Only APIs that are supposed to stay forever should be added now. Especially since the future system is a relatively simple concept (i.e. very quick to add after some design issues have been worked out), so the life time of such a function would be very limited. |
lol I understand that feeling too well
Yes indeed. I think this pull request can be reviewed once again, it might break some installations on vibe.d ~master which use redis but, size_t won't do! |
Thanks, as far as I can tell everything looks good.
Agreed, this is too important to not fix and there is no obvious deprecation path in this case. |
Added blpop and adjusted to signed 64 bit numbers
I was exploring const-correctness and thinking, shouldn't the RedisClient method return types all use immutable storage, and the parameters all have the |
As far as I can see, most parameters/return values are POD types, so they wouldn't benefit from |
Because we're finalizing the Redis API, I thought it would be important to make some better decisions.
First, it's very unsafe for the API to use size_t b/c on i386 platforms forcing 32 bit integers could result in data loss considering Redis sends a string of a 64 bit integers always.
I added
bblpop
as a blocking list pop and a non-blocking listblpop
as a task with concurrency. An issue I pointed out earlier was that redis was not precise on its timeout. The suggestion was to close the connection after 10 seconds, but using a task the best workaround would be to run :auto value = redis.blpop!(string[])(10.seconds, "list1", "list2").receiveTimeout!string(10.seconds);
redis.lpush("list1", "1"); // satisfies the receive loop in blpop
This way, the connection will be recycled and the timeout ends nearer to 10s rather than 10.66s+.
I'd also like to suggest changing the template parameters, ie.
lindex(T : E[], E)
should belindex(T)
b/c there would be more logic requesting the response type rather than specifying the underlying range.