Php+redis implementing the LUA scripting capabilities provided by Redis, redislua_php tutorial

Source: Internet
Author: User
Tags autoload php redis

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 ...

  • Contact Us

    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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.