Skip to content

Add a method to update the TTL of a value in a KV #97

@smcardle

Description

@smcardle

Feature Request

I would like the ability to set the TTL on values in a KV individually AND have the ability to UPDATE that TTL at any time.
I currently use Redis to do exactly this.

Scenario:

Calculating user Profiles is expensive and requires composing data from several source, including 3rd party API's so I cache them to avoid composition as often as possible.
If the Profile is not in the cache I compose the profile then store in cache (expensive)

I store the users profile in a KV with a TTL of 10 minutes, usual user engagement in the app is around 5-8 minutes depending on which features the user is engaged with.

I use the TTL to keep the cache clean, I do not need thousands of inactive user profiles in the cache consuming memory if the user has not interacted with the app for a while.

However, every time I GET the profile from the KV cache I also want to RESET the TTL to be 10 minutes from now, overwriting the TTL stops the eviction if the user spends more time engaged.

Possible options:

  1. Add a TTL parameter on getting a key from the KV that resets the TTL to this new value (ATOMIC request) - preferred
  2. Seperate set TTL method for a key - acceptable

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