[Memcached_DataObject] Do not encache on insert
This resulted in N=0 and empty "modified" in cache.
This commit is contained in:
parent
7e1091eb8c
commit
d7e7396d17
@ -501,8 +501,9 @@ class Memcached_DataObject extends Safe_DataObject
|
|||||||
public function insert()
|
public function insert()
|
||||||
{
|
{
|
||||||
$result = parent::insert();
|
$result = parent::insert();
|
||||||
if ($result) {
|
if ($result !== false) {
|
||||||
$this->encache(); // in case of cached negative lookups
|
// In case of cached negative lookups
|
||||||
|
$this->decache();
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@ -510,11 +511,12 @@ class Memcached_DataObject extends Safe_DataObject
|
|||||||
public function update($dataObject = false)
|
public function update($dataObject = false)
|
||||||
{
|
{
|
||||||
if (is_object($dataObject) && $dataObject instanceof Memcached_DataObject) {
|
if (is_object($dataObject) && $dataObject instanceof Memcached_DataObject) {
|
||||||
$dataObject->decache(); # might be different keys
|
$dataObject->decache(); // might be different keys
|
||||||
}
|
}
|
||||||
$result = parent::update($dataObject);
|
$result = parent::update($dataObject);
|
||||||
if ($result !== false) {
|
if ($result !== false) {
|
||||||
$this->encache();
|
// Cannot encache yet, so decache instead
|
||||||
|
$this->decache();
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@ -582,6 +584,17 @@ class Memcached_DataObject extends Safe_DataObject
|
|||||||
|
|
||||||
public function encache()
|
public function encache()
|
||||||
{
|
{
|
||||||
|
if ($this->N < 1) {
|
||||||
|
// Caching breaks when it is too early.
|
||||||
|
$e = new Exception();
|
||||||
|
common_log(
|
||||||
|
LOG_ERR,
|
||||||
|
'DataObject must be the result of a query (N>=1) before encache() '
|
||||||
|
. str_replace("\n", ' ', $e->getTraceAsString())
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$c = self::memcache();
|
$c = self::memcache();
|
||||||
|
|
||||||
if (!$c) {
|
if (!$c) {
|
||||||
|
Loading…
Reference in New Issue
Block a user