Sets
Sets are also friendly to use - you can use set just like as it's a PHP array:
<?php require_once 'Rediska/Key/Set.php'; $set = new Rediska_Key_Set('set'); $set[] = 'first element'; $set[] = 'second element'; echo count($set); #=> 2 // check if element is in set $isInSet = $set->exists('first element'); #=> true // Iterate set foreach($set as $element) { echo $element; } ?>
All methods
<?php /** * Construct key * * @param string $name Key name * @param integer $expire Expire time in seconds * @param string|null $serverAlias Server alias where key is placed */ public function __construct($name, $expire = null, $serverAlias = null) /** * Add the specified member to the Set * * @param mixin $value Value * @return boolean */ public function add($value) /** * Remove the specified member from the Set * * @param mixin $value Value * @return boolean */ public function remove($value) /** * Move the specified member from one Set to another atomically * * @param string|Rediska_Key_Set $set Set key name or object * @param mixin $value Value * @return boolean */ public function move($set, $value) /** * Get Set length * * @return integer */ public function count() /** * Test if the specified value is a member of the Set * * @prarm mixin $value Value * @return boolean */ public function exists($value) /** * Return the intersection between the Sets * * @param string|array $setOrSets Set key name or object, or array of its * @param string|null $storeKeyName Store intersection to set with key name * @return array|boolean */ public function intersect($setOrSets, $storeKeyName = null) /** * Return the union between the Sets * * @param string|array $setOrSets Set key name or object, or array of its * @param string|null $storeKeyName Store union to set with key name * @return array|boolean */ public function union($setOrSets, $storeKeyName = null) /** * Return the difference between the Sets * * @param string|array $setOrSets Set key name or object, or array of its * @param string|null $storeKeyName Store union to set with key name * @return array|boolean */ public function diff($setOrSets, $storeKeyName = null) /** * Get sorted the elements * * @param string|array $value Options or SORT query string (http://code.google.com/p/redis/wiki/SortCommand). * Important notes for SORT query string: * 1. If you set Rediska namespace option don't forget add it to key names. * 2. If you use more then one connection to Redis servers, it will choose by key name, * and key by you pattern's may not present on it. * @return array */ public function sort($options = array()) /** * Get Set values * * @param string $sort Deprecated * @return array */ public function toArray($sort = null) /** * Add array to Set * * @param array $array */ public function fromArray(array $array) /** * Delete key * * @return boolean */ public function delete() /** * Exists in db * * @return boolean */ public function isExists() /** * Get key type * * @see Rediska#getType * @return string */ public function getType() /** * Rename key * * @param string $newName * @param boolean $overwrite * @return boolean */ public function rename($newName, $overwrite = true) /** * Expire key * * @param integer $secondsOrTimestamp Time in seconds or timestamp * @param boolean $isTimestamp Time is timestamp? Default is false. * @return boolean */ public function expire($secondsOrTimestamp, $isTimestamp = false) /** * Get key lifetime * * @return integer */ public function getLifetime() /** * Move key to other Db * * @see Rediska#moveToDb * @param integer $dbIndex * @return boolean */ public function moveToDb($dbIndex) /** * Get key name * * @return string */ public function getName() /** * Set key name * * @param string $name * @return Rediska_Key_Abstract */ public function setName($name) /** * Set expire time * * @param $secondsOrTimestamp Time in seconds or timestamp * @param $isTimestamp Time is timestamp? Default is false. * @return Rediska_Key_Abstract */ public function setExpire($secondsOrTimestamp, $isTimestamp = false) /** * Get expire seconds or timestamp * * @return integer */ public function getExpire() /** * Is expire is timestamp * * @return boolean */ public function isExpireTimestamp() /** * Set server alias * * @param $serverAlias * @return Rediska_Key_Abstract */ public function setServerAlias($serverAlias) /** * Get server alias * * @return null|string */ public function getServerAlias() /** * Set Rediska instance * * @param Rediska $rediska * @return Rediska_Key_Abstract */ public function setRediska(Rediska $rediska) /** * Get Rediska instance * * @return Rediska */ public function getRediska() ?>