Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use sismember() in contains() rather than getting all the data

  • Loading branch information...
commit 933cc08d816b856d1df931171421a67264cc1601 1 parent fd34fd7
@phpnode authored
Showing with 12 additions and 2 deletions.
  1. +12 −2 ARedisSet.php
View
14 ARedisSet.php
@@ -91,6 +91,7 @@ public function diff($set) {
/**
* Gets the difference between this set and the given set(s), stores it in a new set and returns it
+ * @param ARedisSet|string $destination the destination to store the result in
* @param mixed $set, $set2 The sets to compare to, either ARedisSet instances or their names
* @return ARedisSet a set that contains the difference between this set and the given sets
*/
@@ -149,6 +150,7 @@ public function inter($set) {
}
/**
* Gets the intersection between this set and the given set(s), stores it in a new set and returns it
+ * @param ARedisSet|string $destination the destination to store the result in
* @param mixed $set, $set2 The sets to compare to, either ARedisSet instances or their names
* @return ARedisSet a set that contains the intersection between this set and the given sets
*/
@@ -207,6 +209,7 @@ public function union($set) {
}
/**
* Gets the union of this set and the given set(s), stores it in a new set and returns it
+ * @param ARedisSet|string $destination the destination to store the result in
* @param mixed $set, $set2 The sets to compare to, either ARedisSet instances or their names
* @return ARedisSet a set that contains the union of this set and the given sets
*/
@@ -242,7 +245,7 @@ public function unionStore($destination, $set) {
/**
* Moves an item from this redis set to another
- * @param ARedisIterableSet|string $destination the set to move the item to
+ * @param ARedisSet|string $destination the set to move the item to
* @param mixed $item the item to move
* @return boolean true if the item was moved successfully
*/
@@ -302,7 +305,14 @@ public function copyFrom($data)
else if($data!==null)
throw new CException(Yii::t('yii','List data must be an array or an object implementing Traversable.'));
}
-
+ /**
+ * Determines whether the item is contained in the entity
+ * @param mixed $item the item to check for
+ * @return boolean true if the item exists in the entity, otherwise false
+ */
+ public function contains($item) {
+ return $this->getConnection()->getClient()->sismember($this->name, $item);
+ }
/**
* Returns whether there is an item at the specified offset.
* This method is required by the interface ArrayAccess.
Please sign in to comment.
Something went wrong with that request. Please try again.