39 lines
No EOL
1.3 KiB
Markdown
39 lines
No EOL
1.3 KiB
Markdown
Redis
|
||
|
||
- Getting Started
|
||
https://www.tutorialspoint.com/redis/redis_environment.htm
|
||
`redis-server` to 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
|
||
|
||
- 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 *
|
||
1) "title:1"
|
||
2) "title:2"
|
||
3) "title"
|
||
4) "author:2"
|
||
5) "author"
|
||
6) "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*
|
||
1) "title:1"
|
||
2) "title:2"
|
||
3) "title"
|
||
- retrieving keys with its values
|
||
`for i in $(redis-cli KEYS '*'); do echo $i; redis-cli GET $i; done` |