运行:
cmd进入到redis安装目录,
运行:redis-server.exe redis.windows.conf (即运行安装目录下的两个文件)
运行成功会出现一个类似于罐子的图案。
将该窗口不要关闭,重新打开一个cmd窗口
进入到redis的安装目录
运行:redis-cli.exe -h 127.0.0.1 -p 6379
基本数据类型:
string(字符串)
在redis工作空间中创建键为name的string值
set name "lixl"
在redis工作空间中获得键位name的值
get name
hash(哈希)
在redis工作空间中存储一个键为name的string值到hash中
hmset myhash name "lixl"
*当有多个键值对时:
hmset myhash name "lixl" name1 "lixl1"
在redis工作空间中获取一个存储在hash中键为name的string值
hget myhash name
在redis工作空间中获取指定hash中存储的所有键值对
hgetall myhash
*在你需要一个hash时你并不需要去直接创建一个hash,当执行添加
键值到一个工作空间中并不存在的hash中时,它会自动创建一个hash
并执行添加。
list(列表)
在redis工作空间中存储一个string值到list中
lpush mylist "lixl"
在redis工作空间中获得指定下标间的所有元素
lrange mylist 0 2
set(集合,无序)
cmd进入到redis安装目录,
运行:redis-server.exe redis.windows.conf (即运行安装目录下的两个文件)
运行成功会出现一个类似于罐子的图案。
将该窗口不要关闭,重新打开一个cmd窗口
进入到redis的安装目录
运行:redis-cli.exe -h 127.0.0.1 -p 6379
基本数据类型:
string(字符串)
在redis工作空间中创建键为name的string值
set name "lixl"
在redis工作空间中获得键位name的值
get name
hash(哈希)
在redis工作空间中存储一个键为name的string值到hash中
hmset myhash name "lixl"
*当有多个键值对时:
hmset myhash name "lixl" name1 "lixl1"
在redis工作空间中获取一个存储在hash中键为name的string值
hget myhash name
在redis工作空间中获取指定hash中存储的所有键值对
hgetall myhash
*在你需要一个hash时你并不需要去直接创建一个hash,当执行添加
键值到一个工作空间中并不存在的hash中时,它会自动创建一个hash
并执行添加。
list(列表)
在redis工作空间中存储一个string值到list中
lpush mylist "lixl"
在redis工作空间中获得指定下标间的所有元素
lrange mylist 0 2
set(集合,无序)
在redis工作空间中存储一个String值到zset集合中
zadd set key "value"
在redis工作空间中存储一个String值到zset集合指定位置中
sadd zset index "value"