Permalink
Browse files

simplified record updates from saves to sets

  • Loading branch information...
1 parent 7f7fc47 commit 1c113d2b4c25f1f0d5e69fe7032a16218cac5403 @zircote committed Mar 13, 2012
Showing with 14 additions and 11 deletions.
  1. +14 −11 library/Zend/Cache/Backend/MongoDb.php
@@ -431,15 +431,17 @@ public function getMetadatas($id)
*/
public function touch($id, $extraLifetime)
{
- $data = $this->_getCollection()->findOne(array('_id' => $id));
$data = array(
- '_id' => $id,
- 'mtime' => time(),
- 'expire' => $data['expire'] + $extraLifetime,
- 'tags' => $data['tags'],
- 'content' => $data['content']
+ '_id' => $id
+ );
+ $set = array(
+ '$set' => array(
+ 'mtime' => time(),
+ 'expire' => $data['expire'] + $extraLifetime
+ )
);
- $result = $this->_getCollection()->save($data);
+
+ $result = $this->_getCollection()->update($data, $set);
if ($result) {
return true;
} else {
@@ -482,10 +484,11 @@ public function getCapabilities()
*/
public function ___expire($id)
{
- $data = $this->_getCollection()->findOne(array('_id' => $id));
- $data['mtime'] = time();
- $data['expire'] = time() - 1;
- $this->_getCollection()->save($data);
+ $data = array(
+ 'mtime' => time(),
+ 'expire' => time() - 1
+ );
+ $this->_getCollection()->update(array('_id' => $id),$data);
}
/**

0 comments on commit 1c113d2

Please sign in to comment.