spring-projects / spring-projects/spring-data-redis

@TimeToLiveDate [DATAREDIS-1028]

Open
#1,601 0 comments 0 reactions 1 assignee View on GitHub

@christophstrobl is already working on this.

Since Dec 30, 2020.

type: enhancement
Dominant language
Java
Stars
1.9k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

Chris Haines opened DATAREDIS-1028 and commented

Currently Spring Data Redis has functionality to handle the annotation @TimeToLive. Under the put method inside of RedisKeyValueAdapter.java we have the following code to handle @TimeToLive:

 

if (rdo.getTimeToLive() != null && rdo.getTimeToLive() > 0) {     
  connection.expire(objectKey, rdo.getTimeToLive());     
  // add phantom key so values can be restored     
  byte[] phantomKey = ByteUtils.concat(objectKey, BinaryKeyspaceIdentifier.PHANTOM_SUFFIX);     
  connection.del(phantomKey);     
  connection.hMSet(phantomKey, rdo.getBucket().rawMap());     
  connection.expire(phantomKey, rdo.getTimeToLive() + 300); 
}

 

Consider adding an annotation/interface similar to @TimeToLive(such as @TimeToLiveDate or @TimeToExpire), where the developer can add a date to expire at rather than a long value. Additionally add another case to the conditional above to handle this new annotation/interface and use the connection.expireAt method


1 votes, 1 watchers

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.