redis download address: http://download.redis.io/releases/
Definition
Redis is a key-value storage system. Similar to Memcached, it supports relatively more stored value types, including string (string), list (linked list), set (set), zset (sorted set - ordered set) and hash (hash type). These data types all support push/pop, add/remove, intersection, union, difference, and richer operations, and these operations are all atomic. On this basis, redis supports various different ways of sorting. Like memcached, data is cached in memory to ensure efficiency. The difference is that redis will periodically write updated data to disk or write modification operations to additional record files, and on this basis, master-slave (master-slave) synchronization is achieved.
Redis is a high-performance key-value database. The emergence of redis has largely compensated for the shortcomings of key/value storage such as memcached, and can play a very good supplementary role to relational databases in some situations. It provides Java, C/C, C#, PHP, JavaScript, Perl, Object-C, Python, Ruby, Erlang and other clients, which is very convenient to use.
Redis supports master-slave synchronization. Data can be synchronized from the master server to any number of slave servers, and the slave server can be a master server associated with other slave servers. This allows Redis to perform single-level tree replication. Saving can write data intentionally or unintentionally. Since the publish/subscribe mechanism is fully implemented, when the slave database synchronizes the tree anywhere, it can subscribe to a channel and receive the complete message release record of the master server. Synchronization is helpful for scalability and data redundancy of read operations.
The official website address of redis is very easy to remember, it is redis.io. (I checked specifically and found that the domain name suffix io belongs to the national domain name and is the British Indian Ocean territory)
Currently, Vmware is funding the development and maintenance of the redis project.
Commonly used commands
As far as DB is concerned, Redis's performance is already amazing, not to mention memcachedb and Tokyo Cabinet. The speed of the original memcached seems to only reach this level. Redis basically uses memory storage. The key to persistence is these three instructions: SAVE BGSAVE LASTSAVE...
When receiving the SAVE instruction, Redis will dump the data into a file.
It is worth mentioning its exclusive function: storing lists and collections. This is where it is more competitive with mc and others.
I won’t introduce the stuff that is already in mc, but only list the special ones:
TYPE key — used to get the type of a certain key
KEYS pattern — matches all matches The key of the mode, such as KEYS *, lists all keys. Of course, the complexity is O(n)
RANDOMKEY - returns a random key
RENAME oldkeynewkey— The key can also be renamed
List operation, essence
RPUSH key string — Add a certain value to the end of a key list
LPUSH key string — Add a certain value to the head of a key list
LLEN key — List length
LRANGE key start end — Returns a range of values in the list, equivalent to the paging query in mysql
LTRIM key start end — Only keep a certain range of values in the list
LINDEX key index — Get the value of a specific index number in the list, please note that the complexity is O(n)
LSET key index value — Set the list The value of a certain position in
LPOP key
RPOP key - the same as the LPOP above, it is a head and tail instruction similar to a stack or queue, and can be used as a message queue.
Set operation
SADD key member — Add element
SREM key member — Delete element
SCARD key — Return collection size
SISMEMBER key member — Determine whether a value is in the set
SINTER key1 key2 ... keyN — Get the intersection elements of multiple sets
SMEMBERS key — List all elements of the set
There are also Multiple DB commands, which can replace the db and the data can be isolated. The default is to store it in DB 0.
For more Redis-related technical articles, please visit the Redis Tutorial column to learn!
The above is the detailed content of Where to download redis. For more information, please follow other related articles on the PHP Chinese website!