์•„์ง redis-cli ์„ค์น˜๊ฐ€ ์•ˆ๋˜์–ด์žˆ๋‹ค๋ฉด redis-cli ์„ค์น˜๋ฅผ ์ฐธ๊ณ ํ•ด์ฃผ์„ธ์š”

 

1) ์ „์ฒด key ๊ฐœ์ˆ˜ ์กฐํšŒ

redis.0001.apn.cache..amazonaws.com:6379> info keyspace
# Keyspace
db0:keys=23976,expires=2023,avg_ttl=125758665

2) ์ „์ฒด key ๋ชฉ๋ก ์กฐํšŒ

redis.0001.apn.cache..amazonaws.com:6379> keys *
1) "EmployeeName:Tom Johnson"
2) "ZipCode:67410"
3) "EmployeeName:Tom Hanks"
4) "EmployeeName:Tom Thumb"
5) "ZipCode:15206"

 

keys ๋ช…๋ น์–ด ์‚ฌ์šฉ์‹œ ์ฃผ์˜์ : ์šด์˜ํ™˜๊ฒฝ์—์„œ๋Š” ์‹ ์ค‘ํžˆ ์‚ฌ์šฉํ•  ๊ฒƒ !!

Warning: consider KEYS as a command that should only be used in production environments with extreme care. It may ruin performance when it is executed against large databases. This command is intended for debugging and special operations, such as changing your keyspace layout. Don't use KEYS in your regular application code. If you're looking for a way to find keys in a subset of your keyspace, consider using SCAN or sets.

3) value ํƒ€์ž… ํ™•์ธ (value ํƒ€์ž…์— ๋”ฐ๋ผ ์กฐํšŒ ๋ช…๋ น์–ด๊ฐ€ ๋‹ค๋ฆ„)

redis.0001.apn.cache..amazonaws.com:6379> get "EmployeeName:Tom Johnson"
(error) WRONGTYPE Operation against a key holding the wrong kind of value

redis.0001.apn.cache..amazonaws.com:6379> type "EmployeeName:Tom Johnson"

hash

4) ํƒ€์ž… ์œ ํ˜•๋ณ„ ์กฐํšŒ command

string : get <key>
hash : hgetall <key>
lists : lrange <key> <start> <end>
sets :  smembers <key>
sorted sets : ZRANGEBYSCORE <key> <min> <max>

๋ฐ์ดํ„ฐ ํƒ€์ž…์— ๋”ฐ๋ฅธ ๋” ๋‹ค์–‘ํ•œ ๋ช…๋ น์–ด๋Š” Redis ๊ณต์‹๋ฌธ์„œ ์ฐธ๊ณ 

Redis ๋ชจ๋“  ๋ช…๋ น์–ด ๋ชฉ๋ก

5) ํŠน์ • key์— ๋Œ€ํ•œ value ์กฐํšŒ (hashํƒ€์ž… ๋ฐ์ดํ„ฐ)

redis.0001.apn.cache..amazonaws.com:6379> hgetall "EmployeeName:Tom Johnson"
1) "_class"
2) "com.mycompany.employee.EmployeeName"
3) "name"
4) "Tom Johnson"
5) "id"
6) "2267849"

redis.0001.apn.cache..amazonaws.com:6379> hget "EmployeeName:Tom Johnson" name

"Tom Johnson"