memcache_dataobject supports some DB_DataObject_Cast objects as values
This commit is contained in:
parent
22d6ff25b5
commit
f1ea678aae
@ -128,12 +128,31 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
}
|
||||
|
||||
static function cacheKey($cls, $k, $v) {
|
||||
if (is_object($cls) || is_object($k) || is_object($v)) {
|
||||
if (is_object($cls) || is_object($k) || (is_object($v) && !($v instanceof DB_DataObject_Cast))) {
|
||||
$e = new Exception();
|
||||
common_log(LOG_ERR, __METHOD__ . ' object in param: ' .
|
||||
str_replace("\n", " ", $e->getTraceAsString()));
|
||||
}
|
||||
return common_cache_key(strtolower($cls).':'.$k.':'.$v);
|
||||
if (is_object($v) && $v instanceof DB_DataObject_Cast) {
|
||||
switch ($v->type) {
|
||||
case 'date':
|
||||
$vstr = $v->year . '-' . $v->month . '-' . $v->day;
|
||||
break;
|
||||
case 'blob':
|
||||
case 'string':
|
||||
case 'sql':
|
||||
case 'datetime':
|
||||
case 'time':
|
||||
throw new ServerException("Unhandled DB_DataObject_Cast type passed as cacheKey value: '$v->type'");
|
||||
break;
|
||||
default:
|
||||
throw new ServerException("Unknown DB_DataObject_Cast type passed as cacheKey value: '$v->type'");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$vstr = $v;
|
||||
}
|
||||
return common_cache_key(strtolower($cls).':'.$k.':'.$vstr);
|
||||
}
|
||||
|
||||
static function getcached($cls, $k, $v) {
|
||||
|
Loading…
Reference in New Issue
Block a user