-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
How to determine the prefix in a sublevel #72
Comments
Why do you need this? For context. |
Somewhat relevant: #61 |
thanks for your response. I'm using
So the prefix provides a namespace. |
That stems from old I would have argued against using the name "prefix" in that PR though, because it's not just doing sublevels: it allows mixing in entirely separate databases (that have a different
If you're looking to implement a more limited subset of |
thanks for the comment @vweevers and I think I'm following... I would very much prefer it if my level implementation is unaware of the prefix used for the key in the sub-level. I've written three different abstract level implementations now (one in sql and two KV stores) and it has been pretty straightforward. What I am tripping over is that if I use the same approach as redisdown for sorting keys (sorted set), query / mutation performance will be proportional to the number of items in the level and not the number of items in the smaller sublevel. It looks like redisdown restricts the sorted set key to the sublevel prefix, which I think means query / mutations mutation performance is proportional to the number of items in the specific sublevel (not the level). Is that reasoning correct? Maybe this is premature / over optimization on my part, but I'm also not sure why some sort of namespace metadata in the level commands would be a bad design. |
I am working on a redis level implementation where I need to know which part of the key parameter passed in to
_put()
is the sublevel prefix and what is the key without the prefix. So for this example:So with the default separator, my
_put
implementation would get a key like!sub1!!sub2!foo
. How can my_put
implementation know thatfoo
is the key in the sublevel and the prefix is!sub1!!sub2!
(and is my reasoning so far correct)?I can think of two ways of dealing with this. Override AbstractSublevel and pass the separator in where needed and then use that to extract the prefix from the key. Alternatively, again overriding AbstractSublevel, keep track of the name of each sublevel and pass it down as part of the options.
It seems like neither of these is particularly clean so wondering if there is any better way to do this.
The text was updated successfully, but these errors were encountered: