Redis客户端与Redis建立连接后会自动选择0号数据库,可以随时使用SELECT命令更换数据库,如要选择1号数据库:
redis>SELECT 1
OK
1、查看所有的键:
KEYS *
2、判断一个键是否存在
EXISTS key,如果键存在返回整数类型1,否则返回0。
3、删除键
DEL key [key...]
可以删除一个或多个键,返回值是删除的键的个数。
4、获得键值的数据类型
TYPE key
TYPE命令用来获得键值的数据类型,返回值可能是string(字符串类型)、hash(散列类型)、list(列表类型)、set(集合类型)、zset(有序集合类型)。