remove debugging code for notice streams
darcs-hash:20080928174814-5ed1f-3e431670e52096669e26f6a26edc6ae903763411.gz
This commit is contained in:
parent
f5f9559a60
commit
6c9fdb314c
|
@ -240,23 +240,18 @@ class Notice extends Memcached_DataObject
|
||||||
# If outside our cache window, just go to the DB
|
# If outside our cache window, just go to the DB
|
||||||
|
|
||||||
if ($offset + $limit > NOTICE_CACHE_WINDOW) {
|
if ($offset + $limit > NOTICE_CACHE_WINDOW) {
|
||||||
common_debug('request is too deep, just getting from DB');
|
|
||||||
return Notice::getStreamDirect($qry, $offset, $limit);
|
return Notice::getStreamDirect($qry, $offset, $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
common_debug('CONNECTING TO CACHE');
|
|
||||||
# Get the cache; if we can't, just go to the DB
|
# Get the cache; if we can't, just go to the DB
|
||||||
|
|
||||||
$cache = common_memcache();
|
$cache = common_memcache();
|
||||||
|
|
||||||
|
|
||||||
if (!$cache) {
|
if (!$cache) {
|
||||||
common_debug('Failed connecting to cache; just going to db');
|
|
||||||
return Notice::getStreamDirect($qry, $offset, $limit);
|
return Notice::getStreamDirect($qry, $offset, $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
common_debug('getting from cache');
|
|
||||||
|
|
||||||
# Get the notices out of the cache
|
# Get the notices out of the cache
|
||||||
|
|
||||||
$notices = $cache->get(common_cache_key($cachekey));
|
$notices = $cache->get(common_cache_key($cachekey));
|
||||||
|
@ -264,50 +259,36 @@ class Notice extends Memcached_DataObject
|
||||||
# On a cache hit, return a DB-object-like wrapper
|
# On a cache hit, return a DB-object-like wrapper
|
||||||
|
|
||||||
if ($notices !== FALSE) {
|
if ($notices !== FALSE) {
|
||||||
common_debug('Notices hit: ' . print_r($notices, TRUE));
|
|
||||||
common_debug('Got this many notices: ' . count($notices));
|
|
||||||
$wrapper = new NoticeWrapper(array_slice($notices, $offset, $limit));
|
$wrapper = new NoticeWrapper(array_slice($notices, $offset, $limit));
|
||||||
return $wrapper;
|
return $wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
common_debug('Getting full window from DB.');
|
|
||||||
# Otherwise, get the full cache window out of the DB
|
# Otherwise, get the full cache window out of the DB
|
||||||
|
|
||||||
$notice = Notice::getStreamDirect($qry, 0, NOTICE_CACHE_WINDOW);
|
$notice = Notice::getStreamDirect($qry, 0, NOTICE_CACHE_WINDOW);
|
||||||
|
|
||||||
common_debug('Got notice: ' . print_r($notice, TRUE));
|
|
||||||
|
|
||||||
# If there are no hits, just return the value
|
# If there are no hits, just return the value
|
||||||
|
|
||||||
if (!$notice) {
|
if (!$notice) {
|
||||||
return $notice;
|
return $notice;
|
||||||
}
|
}
|
||||||
|
|
||||||
common_debug('Copying notices to an array');
|
|
||||||
|
|
||||||
# Pack results into an array
|
# Pack results into an array
|
||||||
|
|
||||||
$notices = array();
|
$notices = array();
|
||||||
|
|
||||||
while ($notice->fetch()) {
|
while ($notice->fetch()) {
|
||||||
common_debug('Got notice: ' . print_r($notice, TRUE));
|
|
||||||
$notices[] = clone($notice);
|
$notices[] = clone($notice);
|
||||||
}
|
}
|
||||||
|
|
||||||
common_debug('Array size is: ' . count($notices));
|
|
||||||
|
|
||||||
# Store the array in the cache for next time
|
# Store the array in the cache for next time
|
||||||
|
|
||||||
$result = $cache->set(common_cache_key($cachekey), $notices);
|
$result = $cache->set(common_cache_key($cachekey), $notices);
|
||||||
|
|
||||||
common_debug('memcached result is ' . $result);
|
|
||||||
|
|
||||||
# return a wrapper of the array for use now
|
# return a wrapper of the array for use now
|
||||||
|
|
||||||
$wrapper = new NoticeWrapper(array_slice($notices, $offset, $limit));
|
$wrapper = new NoticeWrapper(array_slice($notices, $offset, $limit));
|
||||||
|
|
||||||
common_debug('Got wrapper: ' . print_r($wrapper, TRUE));
|
|
||||||
|
|
||||||
return $wrapper;
|
return $wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user