Skip to content

Commit

Permalink
Longer default session expiry, load models from a key/blob array (e.g…
Browse files Browse the repository at this point in the history
…. from SORT)
  • Loading branch information
brendonh committed Sep 10, 2011
1 parent 8f10931 commit 5708601
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions yii/modules/Yiidis/components/RedisConnection.php
Expand Up @@ -19,6 +19,7 @@ public function __call($method, $arguments) {
}
}


class RedisConnection extends CApplicationComponent {

public $params;
Expand Down Expand Up @@ -46,6 +47,7 @@ public function set($key, $val, $scenario='update') {
throw new ObjectExistsException($key);
} else {
if (!$this->conn->set($key, $val))
// Wrong. What should this throw?
throw new ObjectExistsException($key);
}

Expand Down
11 changes: 11 additions & 0 deletions yii/modules/Yiidis/components/RedisModel.php
Expand Up @@ -52,6 +52,17 @@ public static function fromJSON($key, $json, $skipPrefix = false) {
return $obj;
}

public static function fromJSONArray($keysAndBlobs, $skipPrefix=false) {
$class = get_called_class();
$objs = array();

for ($i = 0; $i < count($keysAndBlobs); $i += 2) {
$objs[] = $class::fromJSON($keysAndBlobs[$i], $keysAndBlobs[$i+1], $skipPrefix);
}

return $objs;
}

public static function get($key, $skipPrefix=false) {
$class = get_called_class();
if ($skipPrefix) {
Expand Down
2 changes: 1 addition & 1 deletion yii/modules/Yiidis/components/RedisSession.php
Expand Up @@ -5,7 +5,7 @@ class SessionNoUser extends Exception {}
class RedisSession extends RedisModel {

public static $_keyPrefix = 'session';
public static $_expire = 120;
public static $_expire = 3600;

public $_user;

Expand Down

0 comments on commit 5708601

Please sign in to comment.