Skip to content

Get all keys #10

Description

@IgnisDa

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?

Activity

  1. Tinitto commented on Jun 7, 2023

    @Tinitto
    Contributor

    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);
  2. IgnisDa commented on Jun 8, 2023

    @IgnisDa
    Author

    I can not find a length method on Store so the above code you posted is not possible.

  3. Tinitto commented on Jun 8, 2023

    @Tinitto
    Contributor

    Exactly. Both lines are not possible right now. The PR would be to make them possible.

  4. IgnisDa commented on Jun 8, 2023

    @IgnisDa
    Author

    I'd say this would be pretty nice interface.

  5. IgnisDa commented on Jun 12, 2023

    @IgnisDa
    Author

    @Tinitto Any updates on this?

  6. Tinitto commented on Jun 12, 2023

    @Tinitto
    Contributor

    @IgnisDa , My suggestion was you write the code and raise a pull request (PR) because the feature you want does not exist yet.

  7. IgnisDa commented on Jun 12, 2023

    @IgnisDa
    Author

    Ah okay. Will try to do that. I have no experience with writing database systems though.

  8. IgnisDa commented on Jul 7, 2023

    @IgnisDa
    Author

    @Tinitto store.length should 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_all instead.

  9. Tinitto commented on Jul 7, 2023

    @Tinitto
    Contributor

    Expired keys never get retrieved in any way. get and search treat them as nonexistent. I think .length and any other such method should treat them the same way i.e. nonexistent.

  10. IgnisDa commented on Jul 7, 2023

    @IgnisDa
    Author

    What about the proposed .key(n) method?

  11. Tinitto commented on Jul 8, 2023

    @Tinitto
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions