Repository navigation
Get all keys #10
Description
Activity
Hey @IgnisDa .....hmmnn.... interesting feature request. It is not currently possible to get all keys.
Could you try to create it basing on the interface shown in the SO question? And, maybe, raise a PR and we have a look.
So something like:
let num_of_keys: usize = store.length; let first_key: Option<String>= store.key(0);
I can not find a
lengthmethod onStoreso the above code you posted is not possible.Exactly. Both lines are not possible right now. The PR would be to make them possible.
I'd say this would be pretty nice interface.
@Tinitto Any updates on this?
@IgnisDa , My suggestion was you write the code and raise a pull request (PR) because the feature you want does not exist yet.
Ah okay. Will try to do that. I have no experience with writing database systems though.
@Tinitto
store.lengthshould return the number of non-expired keys, right?EDIT: That would be confusing since an expired key could still have an index. I think it would be much better if we implement
get_allinstead.Expired keys never get retrieved in any way.
getandsearchtreat them as nonexistent. I think.lengthand any other such method should treat them the same way i.e. nonexistent.What about the proposed
.key(n)method?That too must not 'see' the expired key-values.
We can look at key expiry as something like a user has set a key with a given value. After some time, that key should be automatically deleted.
That means after that time
ttl, it should not be found in the database in anyway.How we implement it might include some optimizations that maybe leave that expired key-value on file but the user must never see it because to the user, it does not exist.
Thank you for this project. I have been using scdb in my project with huge success!
I do not see a way to get all the keys in the database. Would it be possible to add a
get_all()impl like this SO answer?