Skip to content
This repository was archived by the owner on Aug 4, 2022. It is now read-only.
This repository was archived by the owner on Aug 4, 2022. It is now read-only.

Expiring objects in python-stdnet? #78

Open

Description

@SamuelMarks

One of the main reasons for me to use Redis is as a cache; so it is very important that I can insert keys with specify expires (using Redis; not my own custom expires_in member).

How do I expire keys in python-stdnet?

Activity

  1. jbking commented on Sep 16, 2014

    @jbking
    Contributor

    In my exploring, I can't find such feature. I think Stdnet doesn't support it.
    Because, Stdnet intends to support multi-backend which may not support expiring entry.

    For now, manual deleting (by creation/update datetime) using model is only way.
    I think this is only way for consistency.

  2. SamuelMarks commented on Sep 16, 2014

    @SamuelMarks
    Author

    Many NoSQL stores support this feature, for those that don't you can handle it manually (e.g.: push a timestamp on each expirable record, on get requests check if it's still valid before returning to requester, if expired delete from db)

  3. lsbardel commented on Sep 17, 2014

    @lsbardel
    Owner

    stdnet is a data mapper, one instance of a model can have several keys associated with it. For example, in redis an object has a key for the hash, a key for every index (either sets or zset) and few others for internal use.
    In this respect, it doesn't make lots of sense talking about expiring keys in stdnet, expiring objects could be the equivalent. Such feature is not available, if you need to expire them you can do it programmatically by deleting them.

    If you are using redis as a cache, why do you need the object data mapping of stdnet?
    Do you want to expire keys or objects?
    Can you share your use case?

  4. jbking commented on Sep 17, 2014

    @jbking
    Contributor

    I thought also the feature before.
    A case is making an ephemeral odm object by TTL.
    In redis, automatic expiring redis object is supported natively, and it prevents code bugs which related to deleting.
    But in stdnet, such object may break system data structure.

    By writing above, I got an idea. Let me explain.

    1. introduce a field for TTL, called "_ttl" here.
    2. if a odm object specified as ephemeral object and related backend supports it, set correspond TTL value for the field in Hash.
    3. in retrieving the object in Lua script, returns none if the TTL is over.
    4. also delete the object in stdnet.

    How about this? We can do the step 1, but step 2-4 needs stdnet support.

  5. lsbardel commented on Sep 17, 2014

    @lsbardel
    Owner

    Sounds interesting but I don't need this feature and I don't have time at the moment.
    Happy to assist if anyone decides to implement it.

  6. jbking commented on Sep 18, 2014

    @jbking
    Contributor

    OK, but which branch is better for development?
    Branch dev seems broken by ci..

  7. lsbardel commented on Sep 19, 2014

    @lsbardel
    Owner

    I would create a new branch from master

  8. jbking commented on Sep 20, 2014

    @jbking
    Contributor

    @lsbardel I've made an issue #81 as another topic

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions