Redis-Cli (Redis command line)
ServerConnection
shell
$ redis-cli -c -h {redis-endpoint or host} -p {port}
127.0.0.1:6379>
- Option h: default localhost is optional
- Option p: default value of 6379 can be omitted
- redis-endpoint: All except Port (:6379) from the ElstiCache base endpoint
Data Encryption During Transfer (TLS) is enabled.
shell
$ redis-cli -c -h {redis-endpoint or host} -p {port} --tls
redis-endpoint:port> auth {redis-auth-token or password}
OK
Key Lookup
shell
redis-endpoint:port> keys {pattern}
Check Key
shell
redis-endpoint:port> get {key}
Generate Key
shell
redis-endpoint:port> set {key} {value}
Delete Key
shell
redis-endpoint:port> del {key}
Key query and delete in batches
By default, Redis does not support deletion with patterns
kotlin
redis-cli keys "*Program*" | xargs redis-cli del
Delete All
shell
redis-endpoint:port> FLUSHALL
Check the number of keys
shell
redis-endpoint:port> DBSIZE
Check the commands that are executed
shell
$ redis-cli monitor
OK
1671497361.715468 [0 172.18.0.6:35448] "SMEMBERS" "devdev"
Check memory
shell
127.0.0.1:6379> info memory
# Memory
used_memory:1165728
used_memory_human:1.11M
used_memory_rss:7856128
used_memory_rss_human:7.49M
used_memory_peak:1320304
used_memory_peak_human:1.26M
used_memory_peak_perc:88.29%
used_memory_overhead:897696
used_memory_startup:895712
used_memory_dataset:268032
used_memory_dataset_perc:99.27%
allocator_allocated:1686496
allocator_active:7536640
allocator_resident:8912896
total_system_memory:8233017344
total_system_memory_human:7.67G
used_memory_lua:31744
used_memory_vm_eval:31744
used_memory_lua_human:31.00K
used_memory_scripts_eval:0
number_of_cached_scripts:0
number_of_functions:0
number_of_libraries:0
used_memory_vm_functions:32768
used_memory_vm_total:64512
used_memory_vm_total_human:63.00K
used_memory_functions:184
used_memory_scripts:184
used_memory_scripts_human:184B
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
allocator_frag_ratio:4.47
allocator_frag_bytes:5850144
allocator_rss_ratio:1.18
allocator_rss_bytes:1376256
rss_overhead_ratio:0.88
rss_overhead_bytes:-1056768
mem_fragmentation_ratio:6.86
mem_fragmentation_bytes:6711072
mem_not_counted_for_evict:0
mem_replication_backlog:0
mem_total_replication_buffers:0
mem_clients_slaves:0
mem_clients_normal:1800
mem_cluster_links:0
mem_aof_buffer:0
mem_allocator:jemalloc-5.2.1
active_defrag_running:0
lazyfree_pending_objects:0
lazyfreed_objects:0