Redis String: SETEX
Redis SETEX Command
The Redis SETEX command is used to set some string value with specified timeout in seconds in redis key.
Here are some common uses and scenarios for the "SETEX" command:
- Cache Management: Set values with an automatic expiration to manage cached data.
- Session Handling: Create temporary session tokens or identifiers that expire after a set period.
- Timeouts: Implement time-based locks or timeouts for operations.
- Data Cleanup: Automatically remove temporary data after a specified duration.
- Transient Data: Store data temporarily without manually managing TTL separately.
Syntax:
SETEX KEY_NAME TIMEOUT VALUE
Available since
2.0.0.
Return Value
Simple string reply. OK, if the value is set to key or Null if the value does not set.
Return Value Type
String
Example: Redis SETEX
redis 127.0.0.1:6379> SETEX mykey 60 redis OK redis 127.0.0.1:6379> TTL mykey 60 redis 127.0.0.1:6379> GET mykey "redis
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/redis/redis-setex-key-seconds-value.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics