the value of the specified keyReturns the number of keys that have been deleted (long integers)$redis->delete (' Key1 ', ' key2 ');$redis->delete (Array (' Key3 ', ' key4 ', ' key5 '));TtlGet a key to the time of survivalPersistRemove key for lifetime expirationIf the key expires true if it does not expire falseMset (Redis version 1.1 or above only available)Ass
subscriptions implement mail systems, senders (referred to as publishers in Redis terminology), and receivers (users) receive them. The link sent by this message is called a channel.The Redis client can subscribe to any number of channels.ExampleThe following example shows how to publish a user's conceptual work. In the following example, a client subscription is given a channel named RedischatRedis 127.0.
user's recent access record is also a good application scenario for Redis list, Lpush lpop automatically expired old log log, for the development is still very friendly.
5.Relation List/message Queue
Here two functions in the end, because these two features in the real problems encountered some difficulties, but at a certain stage also did solve many of our problems, so here only to explain.
Message queue is through the list of Lpop and Lpush inte
Redis has created a new way of storing data. When using redis, we don't have to focus on how to put elephants in the refrigerator in the face of monotonous databases, instead, redis uses flexible data structures and data operations to build different refrigerators for different elephants. Common redis Data Types
EXECUTE call sends all bufferred commands to the server, returning
>>> # A list of responses, one for each command.
>>> Pipe.execute ()
[True, ' Baz ']
For ease of use, all commands buffered to pipeline return the pipeline object itself. So the call can be chained up:
Copy Code code as follows:
>>> pipe.set (' foo ', ' Bar '). Sadd (' Faz ', ' Baz '). INCR (' Auto_number '). Execute ()
[True, True, 6]
In addition, pipeline can also guarantee that the buff
define its score. The set uses the score to sort the key.Zrange sorted_set a B [withscores] display all when the value B in the order list is-1 from a to B, [display score of each value]Zrank/zrevrank sorted_set key positive/reverse display the position of the key in the Ordered SetZrem sorted_set key: Delete the key in the sorted setZcard sorted_set [m n] calculates the total number of [scores between m and n] in an ordered set.
Hash (hash type) command
Hset hashset key value: set the value of
multiple "domain value pairs", and each "domain value pair" consists of a field name and a field value;6. The data type used to represent the list in Redis_list:redis;7, the data type used in Redis_set:redis to denote the collection;8. The data type used in Redis_zset:redis to denote an ordered set;9. The data type used in Redis_pubsub:redis to denote "publish-subscribe";10. The data types used in Redis_hyperloglog:redis to denote the hyperloglog cardinality estimation algorithm;11. Data types
', ' value ');$redis-gt;setnx (' key ', ' value ');DeleteDeletes the value of the specified keyReturns the number of key deleted (Long integer)$redis-gt;delete (' Key1 ', ' key2 ');$redis-gt;delete (Array (' Key3 ', ' key4 ', ' key5 '));TtlTo get a key's survival timePersistRemove key that expires in lifetimeIf the key expires true if it does not expire falseMse
mechanism as a NoSQL database. In Redis, the multi/exec/discard/watch of these four commands is the cornerstone of our implementation of a transaction. I believe that this concept is not unfamiliar to developers with relational database development experience, and even so, we will briefly list
In Redis
Implementation characteristics of the
127.0.0.1)
5. SSL Proxy
6. Disable the specified command.
2. Redis master-slave replication:
Redis only needs to be configured on the slave server (slave:
Slaveof 211.122.11.11 6379 # specify the master's ip address and port
Masterauth beijing # This is the password of the master host
Info # view the status of the Master/Slave server.
3. Redis
Tags: inconsistent meaning pre-nested Profile Manager declarative HTM load1.0 Transaction Characteristics (ACID)Atomicity: Atomicity, a transaction cannot be split Consistency: Consistency, the data in the database is in the correct state before the transaction executes, and the data of the database is in the correct state after the
1,connectDescription: The instance is connected to a redis.Parameters: Host:string,port:intReturn value: BOOL successfully returned: TRUE; failed return: FALSE
$redis = new Redis ();$result = $redis-gt;connect (' 127.0.0.1 ', 6379);Var_dump ($result); Result: BOOL (TRUE)?>2,setDescription: Sets the value of key and valueParameter: Key ValueReturn value: BOOL suc
Optimistic lock:
Optimistic lock example http://xmuzyq.javaeye.com/blog/295639Method 1. JDBC uses the following statement:Select a. version... from account as a where (where condition ..)Update account set version = version + 1... (another field) Where version = ?... (Another contidition)
Method 2. hibernate:Public class account {Long ID;.......@ Version // you can also use an XML file for configuration.Int version.......}In hibernate, a corresponding SQL statement is generated to add the vers
In-depth introduction to Redis-redis sentinel cluster, simple introduction to redis-redis1. Sentinel
Sentinel is a Redis high availability solution: a Sentinel system consisting of one or more Sentinel instances can monitor any number of Master servers, and all slave servers under the master server. When the monitored
In-depth introduction to the Redis-redis underlying data structure (I), in-depth introduction to redis-redis1. Overview
I believe everyone who has used Redis knows that Redis is a key-value-based distributed storage system, similar to Memcached, but it is better than Memcach
200 Redis instances on a server, and it crashes. The only way to do this is to make different types of data belong to different applications and separate from each other.So, is there a way for Redis to keep different application data separate from each other and stored on the same instance? is equivalent to the MySQL database, different application data is stored under different databases.Under
useless, for example:(1) database transaction Consistency RequirementsMany web real-time systems do not require strict database transactions, the requirements for read consistency is very low, and some occasions write consistency requirements are not high. Therefore, database transaction management becomes a heavy burden under the high load of database.(2) The realistic and real time demand of the databa
1. What is a transaction:A transaction is a rigorous set of operations in a program, and all operations must be completed successfully, or changes made in each operation will be undone, which is the atomicity of the transaction (either success or failure).2. Transaction characteristics:Transaction characteristics are divided into four: atomicity (atomicity), cons
1. What is a transaction:A transaction is a rigorous set of operations in a program, and all operations must be completed successfully, or changes made in each operation will be undone, which is the atomicity of the transaction (either success or failure).2. Transaction characteristics:Transaction characteristics are divided into four: atomicity (atomicity), cons
useless, for example:(1) database transaction Consistency RequirementsMany web real-time systems do not require strict database transactions, the requirements for read consistency is very low, and some occasions write consistency requirements are not high. Therefore, database transaction management becomes a heavy burden under the high load of database.(2) The realistic and real time demand of the databa
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.