Redis cache expire
Redis cache expire expires a given key (or all keys) for a specific duration. Due to this, you won't be able to access the key/s associated with the cache during chaos.
Use cases
- Determines the resilience of Redis-dependant application when a key expires on a Linux machine.
- This fault can be executed on Ubuntu 16 or higher, Debian 10 or higher, CentOS 7 or higher, RHEL 7 or higher, Fedora 30 or higher, and openSUSE LEAP 15.4 or higher.
- The
linux-chaos-infrastructure
systemd service should be in an active state, and the infrastructure should be inCONNECTED
state.
Fault permissions
The fault uses the root
Linux user and root
user group.
Redis authentication
The following authentication and connection details reside on the same machine where the chaos infrastructure is executed. These details are provided in the /etc/linux-chaos-infrastructure/redis.env
file in the following format:
ADDRESS="127.0.0.1:6379"
PASSWORD=XXXXXXXX
TLS_AUTH_CERT="/path/to/tls-cert"
ADDRESS
is a mandatory field. You can also include PASSWORD
and TLS_AUTH_CERT
fields. You need them only if you have configured your Redis database to facilitate authentication.
ENV name | Description | Example |
---|---|---|
ADDRESS | Location where the Redis server is running. | redis-server.com |
PASSWORD | Password to connect to the Redis database. | password |
TLS_AUTH_CERT | File path to the location where the TLS certificate is stored. | /path/to/file |
Optional tunables
Tunable | Description | Notes |
---|---|---|
key | The key to expire in the Redis cache. | For empty value, all the keys are expired. For more information, go to key. |
expiration | The duration after which the key expires. | Default: 0. For more information, go to expiration. |
database | Redis database where the key exists. | Default: 0. For more information, go to database. |
expiryOption | The options for expiring a Redis key. Refer here for more information. | Supports one of: NX, XX, GT and LT. For more information, go to expiry option. |
duration | Duration through which chaos is injected into the target resource. Should be provided in [numeric-hours]h[numeric-minutes]m[numeric-seconds]s format. | Default: 30s . Examples: 1m25s , 1h3m2s , 1h3s . For more information, go to duration. |
rampTime | Period to wait before and after injecting chaos. Should be provided in [numeric-hours]h[numeric-minutes]m[numeric-seconds]s format. | Default: 0s . Examples: 1m25s , 1h3m2s , 1h3s . For more information, go to ramp time. |
Key
The key
input variable indicates the key to be expired from the Redis cache.
The following YAML snippet illustrates the use of this input variable:
apiVersion: litmuchaos.io/v1alpha1
kind: LinuxFault
metadata:
name: redis-cache-expire
labels:
name: cache-expire
spec:
redisChaos/inputs:
duration: 30s
expiration: ""
key: "KeyName"
database: 1
expiryOption: ""
rampTime: ""
Expiration
The expiration
input value describes the duration after which the key expires.
The following YAML snippet illustrates the use of this input variable:
apiVersion: litmuchaos.io/v1alpha1
kind: LinuxFault
metadata:
name: redis-cache-expire
labels:
name: cache-expire
spec:
redisChaos/inputs:
duration: 30s
expiration: 30s
key: ""
database: 1
expiryOption: ""
rampTime: ""
Expiry option
The expiryOption
input variable provides options to expire a Redis key. It supports NX
, XX
, GT
and LT
. Go to expire command for more information.
The following YAML snippet illustrates the use of this input variable:
apiVersion: litmuchaos.io/v1alpha1
kind: LinuxFault
metadata:
name: redis-cache-expire
labels:
name: cache-expire
spec:
redisChaos/inputs:
duration: 30s
expiration: "5s"
key: ""
database: 1
expiryOption: "GT"
rampTime: ""
Database
The database
input variable is represented as an integer. Its default value is 0.
The following YAML snippet illustrates the use of this input variable:
apiVersion: litmuchaos.io/v1alpha1
kind: LinuxFault
metadata:
name: redis-cache-expire
labels:
name: cache-expire
spec:
redisChaos/inputs:
duration: 30s
expiration: ""
key: ""
database: 1
expiryOption: ""
rampTime: ""