summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-06-04 12:52:05 -0400
committerEvan Prodromou <evan@status.net>2010-06-04 12:52:05 -0400
commitf1ea678aae968c63e9f32adfe1b6da386adb3304 (patch)
treedd9b2497f1fe38eb5e09142f315bbb818229eea4
parent22d6ff25b55d803643ea8d024b56e645be6fc450 (diff)
memcache_dataobject supports some DB_DataObject_Cast objects as values
-rw-r--r--classes/Memcached_DataObject.php25
1 files changed, 22 insertions, 3 deletions
diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php
index 0836c2019..bd9b528db 100644
--- a/classes/Memcached_DataObject.php
+++ b/classes/Memcached_DataObject.php
@@ -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) {
@@ -351,7 +370,7 @@ class Memcached_DataObject extends Safe_DataObject
* low-level database function and add a comment to the
* query string. This should then be visible in process lists
* and slow query logs, to help identify problem areas.
- *
+ *
* Also marks whether this was a web GET/POST or which daemon
* was running it.
*