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
- Sorted sets - ordered collections (“sets”). For each element is stored index (score) for which the "set" and sorted.
- MSET and MSETNX - setting multiple values ​​with one command.
- SRANDMEMBER - returns a random element from the "set".
- RPOPLPUSH - returns the last item from the list and inserts it into the beginning of another.
- New attributes for the SORT command
- Append Only File - a new method of saving data to disk.
- New binary safe protocol
- New storage policy integer values ​​leading to decent memory savings (30% for the database with a large number of integer values).
- Solaris support.
- Bug fixes and performance optimization.
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 .