Redis Remote Dictionary Service--nosql Technology
One or five kinds of basic data types
String list Hash set sorted set (sorted collection)
Two or five kinds of features
(1) InMemory in memory similar to cache, is a key-value storage system
(2) Weakening the transaction is basically not the concept of a transaction, only in some places the transaction is traversed, and its traversal is not encountered errors to stop, but encountered errors regardless of handling.
(3) Cluster environment
(4) Key-value query
(5) Scripting language support
Three
Redis is a single-threaded system,
Support for persistence (cache does not support persistence)
Subscribe/Publish function
(
Redis Message Queuing features
A B C
If the A,B,C server subscribes to a key of the redis, it can be posted to the Redis message queue via a in this key, and Redis will push the message to all B,C servers that subscribe to the key. The Redis itself does not store this data.
)
Iv. the difference between Redis and memcache
Memcache cannot be clustered, Max 1M
Redis can be clustered for a maximum of 1G
Five, redis commonly used between the Web server and database, as a caching system, because it has a persistent function, you can connect to the database, a large number of data in the Redis cache, Web server or application and Redis cache interaction, can improve the performance of program execution.
Web server--redis Server--database
VI. Redis has a third party graphical interface Redis Desktop Manager. But it's not particularly useful.
Seven, REDIS data structure of various commands
Http://redisdoc.com/redis Command Reference
String type
List type
Lpush rpush lpop rpop irange Blpop blocked version
Eight, session management
IX. Cluster Services
1, solve a single node failure
2, read and write separation
Redis Share
Web server--redis Mater
Redis Share
X. REDIS acts as Message Queue
Message Queuing implements subscription/publishing capabilities
Xi. Redis acts as a database server
12, Redis currently need to solve the problem is the memory problem.
The memory is limited, the game data is huge, how to write the data in the Redis memory to the database, or read out the data from the database.
1. Serialize to Local
2, Redis whether to support data write to memory
3, cluster expansion, but this can only solve the capacity of the problem, can not solve the game a large number of dead data problems
Solve memory problem: The main thing is to start from the point of view of the active user from the game dead data.
Methods: When the uniform time to clear the dead data, to determine whether the player Playerbean data more than a certain time, more than set the player Playcache in the state identity is illegal. In Playercache data from a large number of load players in the database into memory, the status is illegal and the data empty is removed.
4, the framework to solve
Redis Elimination expiration mechanism:
Each random 10 keys, idle time non-stop execution. Memory is tight when all traverse, delete the expired key to free memory.