Skip to content

Commit

Permalink
I need to try this on another machine
Browse files Browse the repository at this point in the history
  • Loading branch information
kvz committed Aug 12, 2010
1 parent 527e825 commit 4dd342b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 25 deletions.
27 changes: 15 additions & 12 deletions adapters/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,16 @@ public function flush () {


public function increment ($key, $value = 1) {
$this->set($key, (float)$this->get($key) + $value);
if ($this->set($key, ($new = (float)$this->get($key) + $value))) {
return $new;
}
return false;
}
public function decrement ($key, $value = 1) {
$this->set($key, (float)$this->get($key) - $value);
if ($this->set($key, ($new = (float)$this->get($key) - $value))) {
return $new;
}
return false;
}


Expand Down Expand Up @@ -67,16 +73,14 @@ public function ulistDelete ($ulistKey, $safeKey) {
*
* @return mixed boolean or null
*/
public function ulistSet ($ulistKey, $safeKey = null, $val = null) {
public function ulistSet ($ulistKey, $safeKey, $val) {
$ulist = $this->get($ulistKey);
if (empty($ulist)) {
$ulist = array();
}
if ($safeKey === null) {
$ulist[] = $val;
} else {
$ulist[$safeKey] = $val;
}

$ulist[$safeKey] = $val;

return $this->set($ulistKey, $ulist);
}

Expand All @@ -90,10 +94,9 @@ public function listAdd ($listKey, $val = null) {
$list = array();
}
$list[] = $val;

$this->set($listKey, $list);

return $this->set($listKey, $list);
$success = $this->set($listKey, $list);
prd(compact('val', 'listKey', 'list', 'success'));
return $y;
}
public function getList ($listKey) {
return $this->get($listKey);
Expand Down
4 changes: 2 additions & 2 deletions tests/EventCacheInstTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ protected function setUp ()
$this->EventCacheInst = new EventCacheInst(array(
'app' => 'testapp',
'trackEvents' => true,
'adapter' => 'EventCacheAdapterFile',
//'adapter' => 'EventCacheAdapterApc',
//'adapter' => 'EventCacheAdapterFile',
'adapter' => 'EventCacheAdapterApc',
//'adapter' => 'EventCacheAdapterMemcached',
//'adapter' => 'EventCacheAdapterRedis',
));
Expand Down
29 changes: 18 additions & 11 deletions tests/play.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
error_reporting(E_ALL);
function prd ($arr) {
echo "<xmp>";
if (is_array($arr) && count($arr)) {
Expand All @@ -16,23 +17,29 @@ function prd ($arr) {

$E = new EventCacheInst(array(
'app' => 'testapp',
'trackEvents' => true,
'trackEvents' => false,
//'adapter' => 'EventCacheAdapterFile',
'adapter' => 'EventCacheAdapterApc',
//'adapter' => 'EventCacheAdapterMemcached',
//'adapter' => 'EventCacheAdapterRedis',
));

$E->clear();
$E->delete('lijst');
$E->listAdd('lijst', 'kevin');
$E->listAdd('lijst', 'jp');
prd($E->getList('lijst'));
#$E->flush();

#$E->delete('test');
#$E->write('test', array('kevin'));
#prd($E->read('test'));

$E->ulistSet('lijst', 'naam1', 'kevin');
$E->ulistSet('lijst', 'naam2', 'jp');
$E->ulistSet('lijst', 'num1', 123);
$E->ulistSet('lijst', 'num2', 234);
//$E->delete('lijst');
//$E->listAdd('lijst', 'kevin');
//$E->listAdd('lijst', 'jp');
//$lijst = $E->getList('lijst');
//prd(compact('lijst'));

prd($E->getUlist('lijst'));

$E->ulistSet('ulijst', 'naam1', 'kevin');
$E->ulistSet('ulijst', 'naam2', 'jp');
$E->ulistSet('ulijst', 'num1', 123);
$E->ulistSet('ulijst', 'num2', 234);
$ulijst = $E->getUlist('ulijst');
prd(compact('ulijst'));

0 comments on commit 4dd342b

Please sign in to comment.