📜 ⬆️ ⬇️

Redis 1.2.1 and PHP client Rediska 0.3.0 updated

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


What's new in Redis 1.2.1

Such an impressive list of changes can not but rejoice! Read the full list on the official site.

What's New in Rediska 0.3.0

You can read more about Radish on the official website or in a review on Habré.
')

Examples of work on disrt


Create a key for 2 minutes and save the value if empty:

 <?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(); ?> 

We work with the list:

 <?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; } ?> 

Working with pipelines and executing commands on the specified server:

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

Rediska is an open project: you can participate in the development or become the author of integration with your favorite framework. Contact the authors you will find on the project website .

Source: https://habr.com/ru/post/81917/


All Articles