Php+redis implements the LUA scripting capabilities provided by Redis, Redislua
Phprequire_once"Predis-0.8/autoload.php"; $config[' schema '] = ' TCP '; $config[' Host ']= ' 192.168.1.7 '; $config[' port '] = 6379; $redis=NewPredis\client ($config); classWodeextendsPredis\command\scriptedcommand { Public functionGetkyescount () {return false; } Public functionGetScript () {return<<<lualocal Result= {} forI,v in Ipairs (KEYS) DoResult[i]= Redis.call ("Hgetall",v)EndreturnResultlua; } } $redis->getprofile ()->definecommand (' ri ', ' wode '); $a=$redis->ri (0, ' tt1 ', ' tt2 ', ' tt3 '); Print_r($a);?>
How to set the effective time for the value of the slug in Redis with Lua
There is no ready-made method
If you want to implement the function you say
Generally, the value of the table is increased or decreased by using insert or remove in normal way.
And then an extra listen to the table. Remove the associated value when the specified time is reached
PHP Redis How to solve the reply can
Redis stores data in memory and loses power. Pay attention to this and make a persistence if necessary. The persistence method long story, can refer to the article on the net.
The Redis extension for PHP is called Php-redis. There is a php-redis Chinese manual on the Internet, here is an example:
Connect (' 127.0.0.1 ', 6379); 6379 is the default port $result = $redis->set (' 9639002718 ', "comment"); Set the key value echo $result = $redis->get (' 9639002718 '); Gets the key value $all = $redis->getmultiple (Array (' 9639002718 ', ' 9639002718 ')); Multiple key values are obtained at the same time//No method is provided to obtain all key values. I'm not sure if I can use the following sentence, you can try it. $all = $redis->getmultiple (Array (' * '));
Hope to adopt, thank you for your support!
http://www.bkjia.com/PHPjc/839928.html www.bkjia.com true http://www.bkjia.com/PHPjc/839928.html techarticle Php+redis implements the LUA scripting capabilities provided by Redis, Redislua Php require_once "predis-0.8/autoload.php"; $config [' schema '] = ' TCP '; $conf IG [' Host ']= "192.168.1.7"; $config [' Por ...