Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Shumkov/Rediska
Browse files Browse the repository at this point in the history
  • Loading branch information
shumkov committed Apr 2, 2011
2 parents bc56ea9 + 6e150f3 commit 1bbfa46
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 17 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Version 0.5.5 (March 2, 2011):
Version 0.5.5 (March 8, 2011):
* Feature #4214: Profiler
* Feature #9921: Implement SETBIT, GETBIT, SETRANGE, GETRANGE, STRLEN
* Feature #9932: Implement LINSERT, LPUSHX, RPUSHX
Expand All @@ -16,12 +16,15 @@ Version 0.5.5 (March 2, 2011):
* Improvement #9021: Add getByRank to Rediska_Key_SortedSet
* Improvement #9045: Add getFieldsAndValues() to Rediska_Key_Hash
* Improvement #9052: Add getValues to Rediska_Key_Set and Rediska_Key_List
* Improvement #10093: Add expire argument to Rediska_Key::getOrSetValue
* Bug #4900: Require Rediska bug in Rediska_PubSub_Channel
* Bug #6745: Pub/sub channel can't get Rediska_Connections
* Bug #10061: Subscribe throws exception by timeout if it not specified
* Bug #6746: True subscribe response throws exception
* Bug #6747: Add specified connection to publish
* Bug #6748: Fix memory leaks
* Bug #6777: Fix test bootstrap
* Bug #10159: Break typo in consitent hashing

Version 0.5.1 (October 28, 2010):
* Feature #2033: Implement ZCOUNT
Expand Down
3 changes: 1 addition & 2 deletions library/Rediska/Command/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,7 @@ protected function _argumentsToString($arguments)
$key = !is_integer($name) ? "'$name' => " : '';

if (is_object($value)) {
//$string .= get_class($argument);
$argument = (string)$value;
$argument = get_class($value) . ' $' . $name;
} else if (is_numeric($value)) {
$argument = $value;
} else if (is_string($value)) {
Expand Down
38 changes: 31 additions & 7 deletions library/Rediska/Key.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,15 @@ public function getLength()

/**
* Get value, if value not present set it from chain method
*
* @param $object Object of chain method
*
* @param mixin[optional] $object Object of chain method
* @param integer[optional] $expire Expire
* @param boolean[optional] $expireIsTimestamp If true $expire argument in seconds, or $expire is timestamp
* @return Rediska_Key_GetOrSetValue
*/
public function getOrSetValue($object = null)
public function getOrSetValue($object = null, $expire = null, $expireIsTimestamp = false)
{
return new Rediska_Key_GetOrSetValue($this, $object);
return new Rediska_Key_GetOrSetValue($this, $object, $expire, $expireIsTimestamp);
}

/**
Expand Down Expand Up @@ -245,16 +248,34 @@ class Rediska_Key_GetOrSetValue
*/
protected $_object;

/**
* Expire
*
* @var integer
*/
protected $_expire;

/**
* Is expire in seconds
*
* @var bool
*/
protected $_expireIsTimestamp = false;

/**
* Construct GetOrSetValue provider
*
* @param Rediska_Key $key
* @param object $object Provider object
* @param integer[optional] $expire Expire
* @param boolean[optional] $expireIsTimestamp If true $expire argument in seconds, or $expire is timestamp
*/
public function __construct(Rediska_Key $key, $object = null)
public function __construct(Rediska_Key $key, $object = null, $expire = null, $expireIsTimestamp = false)
{
$this->_key = $key;
$this->_object = $object;
$this->_key = $key;
$this->_object = $object;
$this->_expire = $expire;
$this->_expireIsTimestamp = $expireIsTimestamp;
}

public function __call($method, $args)
Expand All @@ -269,6 +290,9 @@ public function __call($method, $args)
}
$value = call_user_func_array($callback, $args);
$this->_key->setValue($value);
if ($this->_expire !== null) {
$this->_key->expire($this->_expire, $this->_expireIsTimestamp);
}
}

return $value;
Expand Down
2 changes: 1 addition & 1 deletion library/Rediska/KeyDistributor/ConsistentHashing.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function getConnectionsByKeyName($name, $count)
if ($slice >= $this->_slicesCount) {
// If already looped once, something is wrong.
if ($looped) {
break 2;
break;
}

// Otherwise, loop back to the beginning.
Expand Down
4 changes: 3 additions & 1 deletion library/Rediska/PubSub/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ public function getMessage($timeout = null)
}

$connection->setReadTimeout($timeLeft);
} else {
$connection->setReadTimeout(600);
}

try {
Expand All @@ -269,7 +271,7 @@ public function getMessage($timeout = null)
return $response;
} catch (Rediska_Connection_TimeoutException $e) {
if (!$timeout) {
throw $e;
continue;
}

// Reset timeStart if time started from this method
Expand Down
15 changes: 10 additions & 5 deletions library/Rediska/Zend/Profiler/Firebug.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,16 @@ public function stopCallback(Rediska_Profiler_Profile $profile)
$matches = array();
preg_match('/^(.+)\((.*)\)$/s', $commandString, $matches);

$this->getMessage()->addRow(array(
(double)$profile->getElapsedTime(4),
$matches[1],
$matches[2]
));
$row = array((double)$profile->getElapsedTime(4));

if (isset($matches[1])) {
$row[] = $matches[1];
$row[] = $matches[2];
} else {
$row[] = $commandString;
}

$this->getMessage()->addRow($row);

$placeHolders = array(
'%rediskaName%' => $profile->getContext()->getRediska()->getName(),
Expand Down

0 comments on commit 1bbfa46

Please sign in to comment.