The difference between--memcache and memcached:
Memcache is the name of the project,
Memcached is the name of the Memcache server that can execute the file
Basic commands for--memcache:
Get gets the value of a specified key
Set if one does not exist then the update (re-assignment) if present is the combination of the Add method and the Replace method.
Delete Deletes a key
Add a key
Replace updates (update)
Prepend is appended to the front of a value
Stats viewing the status of Memcache
Flush_all empty all the data inside the memcache.
--redis
Key-value Storage System NoSQL data storage
The Redis storage is divided into memory storage, disk storage, and log files, which are configured with three parameters in the configuration file.
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). and memcached only supports strings.
The perimeter of Redis consists of a dictionary of key and value mappings. Unlike other non-relational databases, the type of value in Redis [1] is not limited to strings, but also supports the following abstract data types:
- List of strings
- Unordered, non-repeating collection of strings
- Ordered, non-repeating string collection
- Hash table with key and value as String [1]
As with memcached, data is cached in memory to ensure efficiency. The difference is that Redis periodically writes the updated data to disk or writes the modified operation to the appended record file, and master-slave (Master-Slave) synchronization is implemented on this basis. Data can be synchronized from the primary server to any number of slave servers, from the server to the primary server that is associated with other slave servers. This enables Redis to perform single-layer tree replication . You can write to the data intentionally or unintentionally. Because of the full implementation of the publish/subscribe mechanism, you can subscribe to a channel and receive a complete message release record from the master server when the tree is synchronized anywhere from the database. Synchronization is helpful for the scalability and data redundancy of read operations.
Redis is simply using memory storage, the key to persistence is these three instructions: SAVE BGSAVE lastsave
When the Save command is received, Redis dumps the data into a file. What is worth saying is its exclusive function: storing lists and collections, which is a more competitive place than MC.
Redis is an in-memory database that can usually be used as a cache, and commands commonly used are:
Redis-server start the database with a default port of 6379
REDIS-CLI connection database, default IP is 127.0.0.1, port is 6379
Redis-cli-h 127.0.0.1-p 6380-a password, connect to database, specify host and port number
Select DB Selection database, default is 0, default maximum is 16, can be modified in configuration file (databases 16)
Move key DB move key to new DB
Keys * View all keys
Keys pattern View Matching key
Exists key to determine if the corresponding key exists
Get key gets the value corresponding to key
Mget key1 Key2 Key3 simultaneously gets the value of multiple keys
Dump key returns the value of the serialized key
TTL key gets the remaining lifetime of the key, in seconds
Pttl Key Gets the remaining lifetime of the key, in milliseconds
Type key to view key corresponding value types
Randomkey randomly returns a key
Set key value to set key values corresponding to
Setex Key Timeout value sets the value of key and sets the time-out timeout for key, in seconds
Setnx key value when key does not exist, set key corresponding value
Rename key Newkey with key name Newkey rename key (note: Even if newkey already exists), after renaming, the value of Newkey is the value of the original key
Renamenx key Newkey When Newkey does not exist, rename key with key name Newkey, rename, Newkey value is the value of the original key
Expire key seconds set the expiration time of the key, in seconds
Pexpire key milliseconds set the expiration time of the key, in milliseconds
Persist key move out of key expiration time
Del key Delete key and its value
Del key1 key2 Key3 Delete multiple keys and values
FLUSHDB emptying data from the current database
The difference between Redis and Memecache is that:
1. Storage mode:
Memecache all of the data in memory, after the power outage will be suspended, the data can not exceed the memory size. The data is not lost after the Redis master-slave replication restarts and is loaded again after rebooting.
Redis has a part of the hard disk, which guarantees the persistence of data, support the persistence of data, that is, the Master-slave mode of data backup.
2. Data support type:
Redis has much more data support than Memecache. Provides storage of data structures such as list,set,hash,zset,string
3, using the underlying model is different:
The new version of Redis directly builds its own VM mechanism, because a system function called by a general system can waste a certain amount of time moving and requesting.
4, the operating environment is different:
Redis now officially supports Linux only, eliminating the support for other systems, which can be used to optimize the environment of the system.
The difference between memcache and Redis