What is Redis?
Redis is an open source API that is written in ANSI C, supports the web, can be persisted in memory, key-value databases, and provides multiple languages. Redis is a key-value storage system. Similar to memcached, it supports storing more value types, including string (string), list (linked list), set (set), Zset (sorted set-ordered collection), and hash (hash type). These data types support Push/pop, Add/remove, and intersection-set and difference sets, and richer operations, and these operations are atomic. --a summary of Baidu Encyclopedia
Redis installation (Linux)
Cd/usr/local
wget http://download.redis.io/releases/redis-3.0.7.tar.gz get Redis installation package
Tar xvf redis-3.0.7.tar.gz
CD redis-3.0.7
Make
Make && Install
Redis Common Commands
Redis-server redis.conf # #启动redis
REDIS-CLI # #进入redis客户端 (no password status) | Redis-cli-a YourPassword # #进入redis客户端 (with password status)
REDIS-CLI Shutdown # #停止redis服务
Redis Basic Operations
Keys * # #查看redis中存在的所有的键
Set Word HelloWorld # #向redis中插入键值对数据, key is word, value is HelloWorld
Get word # #根据键取值 with a result of HelloWorld
exists Word # #查看键是否存在
Del Word # #删除当前key
Expire Word # #为相应的键设置过期时间
Persist Word # #移除当前key的过期时间
Randomkey # #随机返回一个key
Type DataList # #返回值得数据类型
Lpush DataList Redis # #向redis插入数据redis到集合头部 (left)
Rpush DataList org # #向redis插入数据org到集合尾部 (right)
Lrange DataList 0 4 # #查询集合中的索引为0-4 Data Flashall # #清空所有数据
For more information, please see the official Redis documentation
How Redis is used in Java: Spring-redis integration
The use of Redis is first written here.
Use of Redis