Git Product home page Git Product logo

Comments (4)

tausten avatar tausten commented on July 25, 2024 1

Heads-up -- in recent versions of https://github.com/go-redis/redis , there is a redis.KeepTTL value (i.e. -1) which maps to the REDIS keepttl option for write operations, but the latest version of cache takes anything < 0 and remaps it to 0, so this doesn't flow through to the underlying redis client, and ultimately doesn't turn into keepttl on the Redis server.

from cache.

knadh avatar knadh commented on July 25, 2024

Can we support this command for more flexible TTL values?

Could you explain what you mean by this?

from cache.

me0den avatar me0den commented on July 25, 2024

For each key in Redis, We have set a TTL value for it. I want to get this TTL value and reuse it for the next time set. Sorry if my eng is bad.

For code example:

// Set ttl 3 mins for key
ttl := 3 * time.Minute
redis.Set(ctx, key, val, ttl).Result()

// after a momemt
ttl, _ := redis.TTL(ctx, key).Result()

// re-set ttl to key
redis.Set(ctx, key, val, ttl).Result()

from cache.

knadh avatar knadh commented on July 25, 2024

Your example is the right way of doing this (you should handle those errors though). If you are doing this in many places, you could just wrap it in a helper function SetWithOldTTL(key, val, cache ...). Don't think such a function in the main lib would be ideal.

from cache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.