]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Notice.php
cache tag streams in Memcached, too
[quix0rs-gnu-social.git] / classes / Notice.php
index 78ebc6aa57894b48b4cab3deebb16fce605efe6a..e72892966c22760d22e9fd1fcd8fac5af6841c6f 100644 (file)
@@ -220,12 +220,12 @@ class Notice extends Memcached_DataObject
 
        static function getStreamDirect($qry, $offset, $limit) {
                
-               $qry .= 'ORDER BY notice.created DESC, notice.id DESC ';
+               $qry .= ' ORDER BY notice.created DESC, notice.id DESC ';
                
                if(common_config('db','type')=='pgsql') {
-                       $qry .= 'LIMIT ' . $limit . ' OFFSET ' . $offset;
+                       $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
                } else {
-                       $qry .= 'LIMIT ' . $offset . ', ' . $limit;
+                       $qry .= ' LIMIT ' . $offset . ', ' . $limit;
                }
 
                $notice = new Notice();
@@ -246,6 +246,7 @@ class Notice extends Memcached_DataObject
                # Get the cache; if we can't, just go to the DB
                
                $cache = common_memcache();
+
                
                if (!$cache) {
                        return Notice::getStreamDirect($qry, $offset, $limit);
@@ -257,7 +258,7 @@ class Notice extends Memcached_DataObject
                
                # On a cache hit, return a DB-object-like wrapper
                
-               if ($notices) {
+               if ($notices !== FALSE) {
                        $wrapper = new NoticeWrapper(array_slice($notices, $offset, $limit));
                        return $wrapper;
                }
@@ -282,11 +283,12 @@ class Notice extends Memcached_DataObject
 
                # Store the array in the cache for next time
                
-               $cache->set(common_cache_key($cachekey), $notices);
+               $result = $cache->set(common_cache_key($cachekey), $notices);
 
                # return a wrapper of the array for use now
                
                $wrapper = new NoticeWrapper(array_slice($notices, $offset, $limit));
+               
                return $wrapper;
        }
        
@@ -301,6 +303,5 @@ class Notice extends Memcached_DataObject
                return Notice::getStream($qry,
                                                                 'public',
                                                                 $offset, $limit);
-);
        }
 }