欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

redis key操作

程序员文章站 2022-07-12 13:37:42
...

root@tts-0001:~# redis-cli 

redis 127.0.0.1:6379> keys *

(empty list or set)

redis 127.0.0.1:6379> set cache ehcache

OK

redis 127.0.0.1:6379> keys *

1) "cache"

redis 127.0.0.1:6379> set file sysfile

OK

redis 127.0.0.1:6379> keys *

1) "file"

2) "cache"

redis 127.0.0.1:6379> randomkey

"file"

redis 127.0.0.1:6379> randomkey

"cache"

redis 127.0.0.1:6379> ttl cache

(integer) -1

redis 127.0.0.1:6379> ttl caches

(integer) -1

redis 127.0.0.1:6379> exists cache

(integer) 1

redis 127.0.0.1:6379> exists caches

(integer) 0

redis 127.0.0.1:6379> rename cache caches

OK

redis 127.0.0.1:6379> keys *

1) "caches"

2) "file"

redis 127.0.0.1:6379> rename caches caches

(error) ERR source and destination objects are the same

redis 127.0.0.1:6379> rename cache caches

(error) ERR no such key

redis 127.0.0.1:6379> type cache

none

redis 127.0.0.1:6379> type caches

string

redis 127.0.0.1:6379> select 1

OK

redis 127.0.0.1:6379[1]> keys *

(empty list or set)

redis 127.0.0.1:6379[1]> select 0

OK

redis 127.0.0.1:6379> move caches 1

(integer) 1

redis 127.0.0.1:6379> move caches 1

(integer) 0

redis 127.0.0.1:6379> select 1

OK

redis 127.0.0.1:6379[1]> keys *

1) "caches"

redis 127.0.0.1:6379[1]> quit