Add Key-Level TTL Support #153
-
Creating an issue for Oracle NoSQL Database to add a feature for setting Time-to-Live (TTL) at the key level similar to Redis. Here's the issue description: In Oracle NoSQL Database, Time-to-Live (TTL) can be set at the row level using a specific column. However, there is currently no direct support for setting TTL at the critical level, similar to how it's done in Redis, Cassandra, Couchbase, Hazelcast, and Infinispan. Desired Behavior: We want to propose adding a feature to Oracle NoSQL Database that allows users to set TTL for individual keys. This would provide more fine-grained control over data expiration and make managing data with varying expiration times easier. Use Case: A common use case is when you have different keys in the database with varying TTLs. For example, in Redis, you can set TTL for a specific key as follows: try (Jedis jedis = pool.getResource()) {
jedis.set("foo", "bar");
jedis.expire("foo", (int) ttl.getSeconds());
} This allows users to control the TTL for each key independently, which is helpful for scenarios where not all data should have the same expiration time. References: |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
This feature is available and has been since we introduced TTL It can also be set in INSERT/UPSERT SQL statements |
Beta Was this translation helpful? Give feedback.
-
Here is an example using the Java SDK and the put API
Retrieving the expiration time using the Java SDK and the get API
Here is an example using SQL (documentation here)
You can use the functions
Note: I will ask to my colleague to add an example for the TTL using the SDK in the documentation |
Beta Was this translation helpful? Give feedback.
-
Thank you both! |
Beta Was this translation helpful? Give feedback.
-
Reopening this discussion that could be interesting for others by default it is showing |
Beta Was this translation helpful? Give feedback.
Here is an example using the Java SDK and the put API
Retrieving the expiration time using the Java SDK and the get API