1.3 KiB
1.3 KiB
Redis
- Getting Started
https://www.tutorialspoint.com/redis/redis_environment.htm
redis-serverto initiate
Then in another terminal
redis-cli
redis 127.0.0.1:6379> ping
PONG
-
Connecting to remote server
redis-cli -h host -p port -a password- Get server information
info: when connected to redis shell not in just bash
- Get server information
-
retrieving keys Retrieving All Existing Keys As it turns out, every SET command we issued above created a new, unique key within our Redis database. To get a list of all current keys that exist, simply use the KEYS command:
KEYS *
- "title:1"
- "title:2"
- "title"
- "author:2"
- "author"
- "author:1" By following KEYS with an asterisk (*) – which acts as a wildcard search – we’re asking Redis to retrieve all keys in the system. Thus, we not only see our two original title and author keys but also the four enumerated versions that followed as well. The syntax following KEYS can be used to search for specific words or phrases within the key, or the exact match as well. Here we want all keys that contain the text 'title':
KEYS title
- "title:1"
- "title:2"
- "title"
-
retrieving keys with its values
for i in $(redis-cli KEYS '*'); do echo $i; redis-cli GET $i; done