<?<span>php </span><span>require_once</span> "predis-0.8/autoload.php"<span>; </span><span>$config</span>['schema'] = 'tcp'<span>; </span><span>$config</span>['host']= "192.168.1.7"<span>; </span><span>$config</span>['port'] = 6379<span>; </span><span>$redis</span> = <span>new</span> Predis\Client(<span>$config</span><span>); </span><span>class</span> wode <span>extends</span><span> Predis\Command\ScriptedCommand { </span><span>public</span> <span>function</span><span> getKyesCount(){ </span><span>return</span> <span>false</span><span>; } </span><span>public</span> <span>function</span><span> getScript(){ </span><span>return</span> <<<<span>LUA local result </span>=<span> {} </span><span>for</span> i,v in ipairs(KEYS) <span>do</span><span> result[i] </span>= redis.call("HGETALL",<span>v) </span><span>end</span> <span>return</span><span> result LUA; } } </span><span>$redis</span>->getProfile()->defineCommand('ri','wode'<span>); </span><span>$a</span> = <span>$redis</span>->ri(0,'tt1','tt2','tt3'<span>); </span><span>print_r</span>(<span>$a</span><span>); </span>?>
There is no ready-made method
If you want to achieve the function you mentioned
Generally speaking, you should increase or decrease the value of the table through insert or remove in the normal way
And then add additional Perform a monitoring on the table and when the specified time is reached, remove the relevant values
Redis will store data in memory and will be lost when power is turned off. Pay attention to this and make it persistent if necessary. The persistence method is difficult to explain in one sentence, you can refer to online articles.
php’s redis extension is called php-redis. There is a Chinese manual for php-redis 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'); // Get the key value $all = $redis->getMultiple(array('9639002718', '9639002718')); // Get multiple key values at the same time // There is no method to get all key values. I'm not sure if the following sentence can be used, you can give it a try. $all = $redis->getMultiple(array('*'));
Hope to adopt it, thank you for your support!