Redis is a very fast key-value database. It can be used as memcached, but the difference from the latter is that Redis saves its data to disk, that is, it can be used to store data (which we successfully do). The main differences from other counterparts are more complex data structures (lists, collections) and atomic operations with them. Read more detailed review Redis on Habré. <?php //   require_once 'Rediska/Key.php'; $key = new Rediska_Key('keyName', 60 * 2); //   $value = $key->getValue(); if ($value === null) { $value = $exampleObject->getNewValue(); $key->setValue($value); } //   $value = $key->getOrSetValue($exampleObject)->getNewValue(); ?>  <?php //   require_once 'Rediska/Key/List.php'; $list = new Rediska_Key_List('list'); //    $list[] = 'first element'; $list[] = 'second element'; //   echo $list[1]; #=> 'second element'; //   $list[0] = 'new first element'; //    echo count($list); #=> 2 //        echo isset($list[0]); #=> true //   foreach($list as $element) { echo $element; } ?>  <?php //  $options = array( 'namespace' => 'MyApplication_', 'servers' => array( 'exapmleAlias' => array('host' => '127.0.0.1'), array('host' => '127.0.0.1', 'port' => 6380) ) ); require_once 'Rediska.php'; $rediska = new Rediska($options); //     "exampleAlias" $rediska->on('exampleAlias')->set('a', 'b'); //     "" $result = $rediska->pipeline()->set('a', 1) ->increment('a', 10) ->rename('a', 'b') ->get('a') ->execute(); //      ?> For more information and examples, see the documentation .Source: https://habr.com/ru/post/81917/
All Articles