Permalink
Browse files

small fixes

  • Loading branch information...
1 parent 22d9129 commit a7a199c7bad836c448cdfebcd59470c38f664948 @phpnode committed Mar 26, 2012
Showing with 37 additions and 6 deletions.
  1. +10 −1 ARedisHash.php
  2. +8 −1 ARedisList.php
  3. +18 −3 ARedisLogRoute.php
  4. +1 −1 ARedisRecord.php
  5. 0 package.json
View
@@ -1,5 +1,14 @@
<?php
-
+/**
+ * Represents a persistent hash stored in redis.
+ * <pre>
+ * $hash = new ARedisHash("myHash");
+ * $hash['a key'] = "some value"; // value is instantly saved to redis
+ * $hash['another key'] = "some other value"; // value is instantly saved to redis
+ * </pre>
+ * @author Charles Pick
+ * @package packages.redis
+ */
class ARedisHash extends ARedisIterableEntity {
/**
View
@@ -1,7 +1,14 @@
<?php
/**
* Represents a redis list.
- *
+ * <pre>
+ * $list = new ARedisList("myList");
+ * $list[] = "an item"; // instantly saved to redis
+ * $list[] = "another item"; // instantly saved to redis
+ * echo count($list); // 2
+ * echo $list->pop() // "another item"
+ * echo count($list); // 1
+ * </pre>
* @author Charles Pick
* @package packages.redis
*/
View
@@ -1,5 +1,9 @@
<?php
-
+/**
+ * A log route that allows log items to be stored or broadcast by redis.
+ * @author Charles Pick
+ * @package packages.redis
+ */
class ARedisLogRoute extends CLogRoute {
/**
* The name of the redis key to use when storing logs
@@ -8,6 +12,12 @@ class ARedisLogRoute extends CLogRoute {
public $redisKey;
/**
+ * Whether to broadcast log messages via pub/sub instead of saving them
+ * @var boolean
+ */
+ public $useChannel = false;
+
+ /**
* Holds the redis connection
* @var ARedisConnection
*/
@@ -42,7 +52,7 @@ public function getConnection()
}
/**
- * Stores log messages into database.
+ * Stores or broadcasts log messages via redis.
* @param array $logs list of log messages
*/
protected function processLogs($logs)
@@ -67,7 +77,12 @@ protected function processLogs($logs)
else {
$json = json_encode($item);
}
- $redis->publish($this->redisKey, $json);
+ if ($this->useChannel) {
+ $redis->publish($this->redisKey, $json);
+ }
+ else {
+ $redis->zAdd($this->redisKey,$log[3],$json);
+ }
}
}
}
View
@@ -84,7 +84,7 @@ public function __construct($scenario = "insert")
* <pre>
* public static function model($className=__CLASS__)
* {
- * return parent::model($className);
+ * return parent::model($className);
* }
* </pre>
*
View
0 package.json 100644 → 100755
No changes.

0 comments on commit a7a199c

Please sign in to comment.