PHP memcache Ring Queue class. Novice, did not learn the data structure, because the business needs, so just the bite-bullet simulation! The prototype is the PHP memcache queue code Lusi shared on Oschina. In order to make the queue readily available, and not by the int length cross-border danger (single chain take head self-increment words do not have to deal with the possibility of cross-border), so simply rewrite into a ring queue. There may be bugs, forget forgive!
/
PHPmemcache ring queue
PHP memcache ring queue class. Beginner, I have never learned the data structure. because of the business needs, I just tried it hard! The original form is the PHP memcache queue code shared by lusi on oschina. To enable the queue to enter and exit at any time, and avoid the danger of the int length crossing the border (if a single chain uses the Head auto-increment function, it is possible that the process does not cross the border), simply rewrite the queue to a
certain amount of overhead, the use of database row-level locks is not necessarily reliable, performance is not reliable)
Distributed locks Based on redisDistributed locks Based on the setnx () and expire () Methods of redisSetnx ()Setnx is set if not exists. It mainly has two parameters: setnx (Key, value ). This method is atomic. If the key does not exist, the current key is successfully set and 1 is returned. If the current key already exists, the
I believe that we have a little knowledge of data expiration in Redis, this article mainly introduces the data expiration policy in Redis, the article introduces in detail through the example code, I believe that everyone's understanding and learning has a certain reference value, the need for friends can reference, hope to help everyone.
1, the Expiration time of key in Redis
Set the data expiration time by expire the key seconds command. A return o
1, the Expiration time of key in RedisSet the data expiration time by expire the key seconds command. A return of 1 indicates that the setting was successful, and returning 0 indicates that the key does not exist or the expiration is not successfully set. After the expiration time is set on the key, the key will be automatically deleted after the specified number of seconds. Keys that have been assigned an expiration time are known to be unstable in R
Redis provides a lifetime for the key, and the lifetime is permanent when no life time is specified. Redis will automatically delete this key when the time expires. You can use the expire command, the time unit seconds, if a key is set to a limited lifetime, then the set key will be reset when the value is again set to permanent:SET Session:captcha sd2aEXPIRE Session:captcha 600
Cancels the lifetime, the key lifetime is set to permanent, is persist:P
Scancommand (redisclient *c)/* Scan command */void dbsizecommand (redisclient *c)/* Total number of DB dictionaries used by the client */void Lastsaveco Mmand (redisclient *c)/* Server Last saved Operation */void Typecommand (redisclient *c)/* Client query for key type */void Shutdowncommand ( Redisclient *c)/* Shutdown terminate command, server to do the last save Operation */void Renamegenericcommand (redisclient *c, int nx)/* For key rename operation */void Renam Ecommand (redisclient *c)/*
Config.lua is loaded. When the request arrives, by default, the Srcache is off, and in Monitor.lua, the current request is matched in a regular match, and once the match is successful, the cache key is computed, the Srcache is set to ON, and the Content.lua is finished and read and written.Look at the contents of the "config.lua" file, which is used primarily to record some global configuration information:Phoenix = {}phoenix["memcached"] = { default = { Timeout = "", keepalive
Today put 3 sites, one of the CodeIgniter site, and two wordpres sites, all moved to a domain name below, but also quite a lot of trouble, recently always like toss!
First, these three sites now have domain names:
http://your domain name (WordPress)
http://your domain/tanteng/(wordpress)
http://your domain/hongzhiban/(CodeIgniter)
If not in the BAE3.0 environment, the other site directly moved over, the database table put together a common database, and then change the database connection c
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.