Install and use Redis in Linux
What is Redis?
Redis is an open-source log-type and Key-Value database written in ansi c language that supports Network, memory-based persistence, and provides APIs in multiple languages. Redis is a key-value storage system. Similar to Memcached, Memcached supports more storage value types, including string, list, set, and zset) and hash (hash type ). These data types support push/pop, add/remove, Intersection Set and difference set, and more abundant operations, and these operations are atomic.
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
Common Redis commands
Redis-server redis. conf # Start redis
Redis-cli # enter the redis client (without a password) | redis-cli-a yourpassword # enter the redis client (with a password)
Redis-cli shutdown # Stop the redis Service
Basic Redis operations
Keys * ## view all keys in redis
Set word helloworld # Insert key-value pair data to redis. The key is word and the value is helloworld.
Get word # according to the key value, the result is helloworld
Exists word # Check whether the key exists
Del word # Delete the current key
Expire word 10 # Set the expiration time for the corresponding key
Persist word # Remove the expiration time of the current key
Randomkey # Return a random key
Type datalist # Return Value Data type
Lpush datalist redis # insert data into redis to the set header (left)
Rpush datalist org # insert data org to the end of the Set (right) to redis)
Lrange datalist 0 4 # flashall # Clear all data whose index is 0-4 in the query set
For more operations, see the official apsaradb for redis user manual.
Use of redis in java: spring-redis Integration
For redis usage, write it here first.
You may also like the following articles about Redis. For details, refer:
Install and test Redis in Ubuntu 14.04
Basic configuration of Redis master-slave Replication
Redis cluster details
Install Redis in Ubuntu 12.10 (graphic explanation) + Jedis to connect to Redis
Redis series-installation, deployment, and maintenance
Install Redis in CentOS 6.3
Learning notes on Redis installation and deployment
Redis. conf
Redis details: click here
Redis: click here
This article permanently updates the link address: