the * and number (matching one character) $redis->set (' foo1′,123);
$redis->set (' foo2′,456); $redis->keys (' foo* '); Returns the array $redis->keys (' F?o? ') of Foo1 and Foo2; Ibid.//randomkey Returns a key $redis->randomkey () randomly; It is possible to return to '
time settings are evicted randomly.
Volatile-ttl: In order to make space for the new data, evict only keys with an expire set, and try to evict keys with a shorter time to live (TTL) first.
To use memory for newly added data, keys with the minimum expiration time and TTL are evicted.
The specified ies volatile-lru, volatile-random and volatile-
This document is a Chinese php-redis document. it mainly describes some of the commands officially provided by apsaradb for redis. For more information, see
Phpredis is an extension of php, and the efficiency is quite high. It provides the linked list sorting function to create memory-level module business relationships.
Useful. The following are the command tips officially provided by
commands
Key/value-related commands.
Keys * # Query all
Keys user * # query the specified
Exists user: 001 # determine whether the user exists.
Del name # Delete the specified key.
Expire addr 10 # set the Expiration Time
Ttl addr # query the Expiration Time
Select 0 # select database
Move age 1 # move age to database 1.
Get age # get
Persist age # the expiration time of the age to be removed.
Randomkey # returns a random key.
Rename name1 name2 # re
? But it doesn't matter, getbit should not have problems $redis->getbit (' binary ', 31);
Returns the 1//keys Fuzzy Lookup function, supports the * and number (matching one character) $redis->set (' foo1′,123);
$redis->set (' foo2′,456); $redis->keys (' foo* '); Returns the array $
practices.3. Best practice 3.1 Apply good fault-tolerant mechanism
Connect or request an exception, connect retry and reconnect.
Retry time should be greater than cluster-node-time timeor the emphasis on fault tolerance, this is not for cluster, all application design is applicable.
3.2 Develop the Code of development
Slow queries, process CPU 100%, client requests slow, or even time out.
Avoid generating Hot-key, which causes the node to become the short board of
$redis = new Redis ();
Connect, open link Redis service
Parameters
host:string, service address
Port:int, port number
timeout:float, link duration (optional, default = 0, unlimited link time)
Note: There is also time in redis.conf, default is 300
Pconnect, Popen does not actively close the link
Refer to above
SetOption Setting up
need to select a key recycling policy that modifies the value of the Maxmemory-policy property in the redis.conf configuration file. If the key in the Redis dataset is set to expire, then the "Volatile-ttl" strategy is the better choice. However, if key fails to expire quickly when the maximum memory limit is reached, or the expiration time is not set at all. It is appropriate to set the value of "ALLKEYS-
; remove a random key, any key# Volatile-ttl->Remove the expired key (minor TTL)# Noeviction-> NO removal is allowed, but a write error is returned.##NOTE: For the above policy, if there is no suitable key, you can remove it. When writing, Redis will return an error.## Write Commands include: set setnxSetex append# Incr decr rpush lpush rpushx lpushx linsert lset
This document is a Chinese php-redis document. it mainly describes some of the commands officially provided by redis. if you have any need, you can refer to phpredis as an extension of php, efficiency is quite high with the linked list sorting function, for creating memory-level module business relationships
Useful. The following are the command tips officially provided by
elimination policy. The default value is volatile-lru. Currently, six policies are supported:
A. volatile-lru => remove the key with an expire set using an LRU algorithm;
B. allkeys-lru-> remove any key accordingly to the LRU algorithm
C. volatile-random-> remove a random key with an expire set
D. allkeys-random-> remove a random key, any key
E. volatile-ttl-> remove the key with the nearest expire time (minor TT
retrieval
$ Redis-> setbit ('binary ', 31,1); // indicates storing 1 in 31st bits. Is there a problem with the size? But it doesn't matter. getbit should be okay.
$ Redis-> getbit ('binary ', 31); // return 1
// The keys fuzzy search function supports the * and? (Match one character)
$ Redis-> set ('foo1', 123 );
$
1MBIf the master Redis is still unable to connect to the slave redis after waiting for some time, the data in the buffer queue will be cleaned up. We can set the length of time the master Redis will wait. If set to 0, it means never clean up. The default is 1 hours.Repl-backlog-ttl 3600We can give a lot of priority fr
should set the "MaxMemory" value to 45% of the system's memory, because the snapshot requires a memory-time copy of the entire data set, which means that if 45% is currently used, it becomes 95% (45%+45%+5%) during the snapshot, where 5% is reserved for other expenses. If the snapshot feature is not turned on, the maxmemory can be set to 95% of the system's available memory.
When memory usage reaches the maximum threshold set, you need to select a key recycling policy that modifies the value o
clients do not modify this key value, therefore, we need to re-execute the entire function after EXEC fails.
After EXEC is executed, the monitoring of all keys is canceled. You can also use the unwatch command to cancel monitoring.
Iv. survival time
Use the expire command to set the survival time of a key. redis will automatically delete it after that.
If you want to delete the session: 29e3d key 15 minutes later
1 indicates success, 0 indicates th
a size end problem? But it doesn't matter, getbit should not have problems $redis->getbit (' binary ', 31); Returns the 1//keys Fuzzy Lookup feature, which supports the * number and the (match one character) $redis->set (' foo1′,123); $redis->set (' foo2′,456 '); $redis->keys (' foo* ') ); Returns the Array$
Php-redis Chinese Document original address: http://www.cnblogs.com/weafer/archive/2011/09/21/2184059.htmlPhpredis is an extension of PHP, the efficiency is quite high with the list sorting function, to create a memory-level module business relationshipThis is useful for Redis's official command:As follows:Https://github.com/owlient/phpredis (Redis 2.0.4 supported)Redis
Phpredis is an extension of PHP, the efficiency is quite high with the list sorting function, to create a memory-level module business relationshipThis is useful for Redis's official command:As follows:Https://github.com/owlient/phpredis (Redis 2.0.4 supported)Redis::__construct constructor function$redis = new Redis (
Phpredis is an extension of PHP, the efficiency is quite high with the list sorting function, to create a memory-level module business relationshipThis is useful for Redis's official command:As follows:Https://github.com/owlient/phpredis (Redis 2.0.4 supported)Redis::__construct constructor function$redis = new Redis (
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.