]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Memcached_DataObject.php
Inbox::streamNotices() with deletion compensation: inbox paging should more or less...
[quix0rs-gnu-social.git] / classes / Memcached_DataObject.php
index b60aa7911d66c2ff58805068ff0b21204786cf0a..ab65c30ce28579a8684b4e9fa8d9cc8124d2b833 100644 (file)
@@ -147,6 +147,7 @@ class Memcached_DataObject extends DB_DataObject
     {
         $result = parent::insert();
         if ($result) {
+            $this->fixupTimestamps();
             $this->encache(); // in case of cached negative lookups
         }
         return $result;
@@ -159,6 +160,7 @@ class Memcached_DataObject extends DB_DataObject
         }
         $result = parent::update($orig);
         if ($result) {
+            $this->fixupTimestamps();
             $this->encache();
         }
         return $result;
@@ -366,7 +368,7 @@ class Memcached_DataObject extends DB_DataObject
     }
 
     /**
-     * sends query to database - this is the private one that must work 
+     * sends query to database - this is the private one that must work
      *   - internal functions use this rather than $this->query()
      *
      * Overridden to do logging.
@@ -529,4 +531,51 @@ class Memcached_DataObject extends DB_DataObject
 
         return $c->delete($cacheKey);
     }
+
+    function fixupTimestamps()
+    {
+        // Fake up timestamp columns
+        $columns = $this->table();
+        foreach ($columns as $name => $type) {
+            if ($type & DB_DATAOBJECT_MYSQLTIMESTAMP) {
+                $this->$name = common_sql_now();
+            }
+        }
+    }
+
+    function debugDump()
+    {
+        common_debug("debugDump: " . common_log_objstring($this));
+    }
+
+    function raiseError($message, $type = null, $behaviour = null)
+    {
+        throw new ServerException("DB_DataObject error [$type]: $message");
+    }
+
+    static function cacheGet($keyPart)
+    {
+        $c = self::memcache();
+
+        if (empty($c)) {
+            return false;
+        }
+
+        $cacheKey = common_cache_key($keyPart);
+
+        return $c->get($cacheKey);
+    }
+
+    static function cacheSet($keyPart, $value)
+    {
+        $c = self::memcache();
+
+        if (empty($c)) {
+            return false;
+        }
+
+        $cacheKey = common_cache_key($keyPart);
+
+        return $c->set($cacheKey, $value);
+    }
 }