From: Evan Prodromou Date: Fri, 26 Sep 2008 16:09:41 +0000 (-0400) Subject: caching layer for DB/DataObject X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e2e6bbb298e8b41573e78c6acfd764cc95f6954a;p=quix0rs-gnu-social.git caching layer for DB/DataObject I added a new class, Memcached_DataObject, that will (optionally) fetch data out of a memcached server if it's available. This only works on 'staticGet'. Methods that write to the database (insert, update, delete) will clear and set the cache correctly, too. darcs-hash:20080926160941-5ed1f-922de078b4c1941853ad014edf9a17fae486f8cf.gz --- diff --git a/classes/Avatar.php b/classes/Avatar.php index 7aaf787b2e..ad5ccd7ba7 100644 --- a/classes/Avatar.php +++ b/classes/Avatar.php @@ -2,9 +2,9 @@ /** * Table Definition for avatar */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class Avatar extends DB_DataObject +class Avatar extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -21,7 +21,7 @@ class Avatar extends DB_DataObject public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Avatar',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Avatar',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/Confirm_address.php b/classes/Confirm_address.php index f18d554a36..9f28dda736 100644 --- a/classes/Confirm_address.php +++ b/classes/Confirm_address.php @@ -2,9 +2,9 @@ /** * Table Definition for confirm_address */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class Confirm_address extends DB_DataObject +class Confirm_address extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -20,7 +20,7 @@ class Confirm_address extends DB_DataObject public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Confirm_address',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Confirm_address',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/Consumer.php b/classes/Consumer.php index 6f4513f332..5e457a3fc3 100644 --- a/classes/Consumer.php +++ b/classes/Consumer.php @@ -2,9 +2,9 @@ /** * Table Definition for consumer */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class Consumer extends DB_DataObject +class Consumer extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -16,7 +16,7 @@ class Consumer extends DB_DataObject public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Consumer',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Consumer',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/Fave.php b/classes/Fave.php index 572dc232ea..67cdf2cca4 100644 --- a/classes/Fave.php +++ b/classes/Fave.php @@ -2,9 +2,9 @@ /** * Table Definition for fave */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class Fave extends DB_DataObject +class Fave extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -15,7 +15,7 @@ class Fave extends DB_DataObject public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Fave',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Fave',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/Foreign_link.php b/classes/Foreign_link.php index 0c6df8ffcd..ba6624d069 100644 --- a/classes/Foreign_link.php +++ b/classes/Foreign_link.php @@ -2,9 +2,9 @@ /** * Table Definition for foreign_link */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class Foreign_link extends DB_DataObject +class Foreign_link extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -21,7 +21,7 @@ class Foreign_link extends DB_DataObject public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Foreign_link',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Foreign_link',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/Foreign_service.php b/classes/Foreign_service.php index ec38c54171..61aa4616eb 100644 --- a/classes/Foreign_service.php +++ b/classes/Foreign_service.php @@ -2,9 +2,9 @@ /** * Table Definition for foreign_service */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class Foreign_service extends DB_DataObject +class Foreign_service extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -17,7 +17,7 @@ class Foreign_service extends DB_DataObject public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Foreign_service',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Foreign_service',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/Foreign_subscription.php b/classes/Foreign_subscription.php index b8cbed8ca6..742ea33338 100644 --- a/classes/Foreign_subscription.php +++ b/classes/Foreign_subscription.php @@ -2,9 +2,9 @@ /** * Table Definition for foreign_subscription */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class Foreign_subscription extends DB_DataObject +class Foreign_subscription extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -16,7 +16,7 @@ class Foreign_subscription extends DB_DataObject public $created; // datetime() not_null /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Foreign_subscription',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Foreign_subscription',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/Foreign_user.php b/classes/Foreign_user.php index 2b6e810158..f1ad6e6dc2 100644 --- a/classes/Foreign_user.php +++ b/classes/Foreign_user.php @@ -2,9 +2,9 @@ /** * Table Definition for foreign_user */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class Foreign_user extends DB_DataObject +class Foreign_user extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -18,7 +18,7 @@ class Foreign_user extends DB_DataObject public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Foreign_user',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Foreign_user',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/Invitation.php b/classes/Invitation.php index cc3c3b9370..a025d10b14 100644 --- a/classes/Invitation.php +++ b/classes/Invitation.php @@ -2,9 +2,9 @@ /** * Table Definition for invitation */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class Invitation extends DB_DataObject +class Invitation extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -17,7 +17,7 @@ class Invitation extends DB_DataObject public $created; // datetime() not_null /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Invitation',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Invitation',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/Memcached_Object.php b/classes/Memcached_Object.php new file mode 100644 index 0000000000..a11c9883ff --- /dev/null +++ b/classes/Memcached_Object.php @@ -0,0 +1,144 @@ +. + */ + +if (!defined('LACONICA')) { exit(1); } + +require_once 'classes/Memcached_DataObject.php'; + +class Memcached_DataObject extends DB_DataObject +{ + static function &staticGet($cls, $k, $v=NULL) { + $i = $this->getcached($cls, $k, $v); + if (!is_null($i)) { + return $i; + } else { + $i = parent::staticGet($k, $v); + if (!is_null($i)) { + $i->encache(); + } + return $i; + } + } + + function insert() { + $result = parent::insert(); + if ($result) { + $this->encache(); + } + return $result; + } + + function update($orig=NULL) { + if (!is_null($orig)) { + $orig->decache(); # might be different keys + } + $result = parent::update($orig); + if ($result) { + $this->encache(); + } + } + + function delete() { + $this->decache(); # while we still have the values! + return parent::delete(); + } + + static function memcache() { + if (!common_config('memcached', 'enabled')) { + return NULL; + } else { + $cache = new Memcache(); + $res = $cache->connect(common_config('memcached', 'server'), + common_config('memcached', 'port')); + return ($res) ? $cache : NULL; + } + } + + static function cacheKey($cls, $k, $v) { + return common_cache_key(strtolower($cls) . ':' . + $k . ':' . + $v); + } + + static function getcached($cls, $k, $v) { + $c = Memcached_DataObject::memcache(); + if (!$c) { + return false; + } else { + return $c->get(Memcached_DataObject::cacheKey($cls, $k, $v)); + } + } + + function keyTypes() { + global $_DB_DATAOBJECT; + if (!isset($_DB_DATAOBJECT['INI'][$this->_database][$this->__table."__keys"])) { + $this->databaseStructure(); + + } + return $_DB_DATAOBJECT['INI'][$this->_database][$this->__table."__keys"]; + } + + function encache() { + $c = $this->memcache(); + if (!$c) { + return false; + } else { + $primary = array(); + $types = ksort($this->keyTypes()); + foreach ($types as $key => $type) { + if ($type == 'K') { + $primary[] = $key; + } else { + $c->set($this->cacheKey($this->tableName(), $key, $this->$key), + $this); + } + } + # XXX: figure out what to do with compound pkeys + if (count($primary) == 1) { + $key = $primary[0]; + $c->set($this->cacheKey($this->tableName(), $key, $this->$key), + $this); + } + } + } + + function decache() { + $c = $this->memcache(); + if (!$c) { + return false; + } else { + $primary = array(); + $types = ksort($this->keyTypes()); + foreach ($types as $key => $type) { + if ($type == 'K') { + $primary[] = $this->$key; + } else { + $c->delete($this->cacheKey($this->tableName(), $key, $this->$key), + $this); + } + } + # XXX: figure out what to do with compound pkeys + if (count($primary) == 1) { + $key = $primary[0]; + $c->delete($this->cacheKey($this->tableName(), $key, $this->$key), + $this); + } + } + } +} diff --git a/classes/Message.php b/classes/Message.php index a903161f78..12ec10846b 100644 --- a/classes/Message.php +++ b/classes/Message.php @@ -2,9 +2,9 @@ /** * Table Definition for message */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class Message extends DB_DataObject +class Message extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -22,7 +22,7 @@ class Message extends DB_DataObject public $source; // varchar(32) /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Message',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Message',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/Nonce.php b/classes/Nonce.php index 987e8d1e85..258726c1e3 100644 --- a/classes/Nonce.php +++ b/classes/Nonce.php @@ -2,9 +2,9 @@ /** * Table Definition for nonce */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class Nonce extends DB_DataObject +class Nonce extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -18,7 +18,7 @@ class Nonce extends DB_DataObject public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Nonce',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Nonce',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/Notice.php b/classes/Notice.php index 2d880f8cb3..4af81f9190 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -22,9 +22,9 @@ if (!defined('LACONICA')) { exit(1); } /** * Table Definition for notice */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class Notice extends DB_DataObject +class Notice extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -43,7 +43,7 @@ class Notice extends DB_DataObject public $source; // varchar(32) /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Notice',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Notice',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/Notice_source.php b/classes/Notice_source.php index fe6d3d4f1d..b05ee9f56e 100644 --- a/classes/Notice_source.php +++ b/classes/Notice_source.php @@ -2,9 +2,9 @@ /** * Table Definition for notice_source */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class Notice_source extends DB_DataObject +class Notice_source extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -17,7 +17,7 @@ class Notice_source extends DB_DataObject public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Notice_source',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Notice_source',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/Notice_tag.php b/classes/Notice_tag.php index 3731d84145..5dca41a7ab 100644 --- a/classes/Notice_tag.php +++ b/classes/Notice_tag.php @@ -2,9 +2,9 @@ /** * Table Definition for notice_tag */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class Notice_tag extends DB_DataObject +class Notice_tag extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -15,7 +15,7 @@ class Notice_tag extends DB_DataObject public $created; // datetime() not_null /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Notice_tag',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Notice_tag',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/Profile.php b/classes/Profile.php index 5f88caf2c4..ab1880470a 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -22,9 +22,9 @@ if (!defined('LACONICA')) { exit(1); } /** * Table Definition for profile */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class Profile extends DB_DataObject +class Profile extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -41,7 +41,7 @@ class Profile extends DB_DataObject public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Profile',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Profile',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/Queue_item.php b/classes/Queue_item.php index 14d2e34b57..2fb5b2920a 100644 --- a/classes/Queue_item.php +++ b/classes/Queue_item.php @@ -2,9 +2,9 @@ /** * Table Definition for queue_item */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class Queue_item extends DB_DataObject +class Queue_item extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -16,7 +16,7 @@ class Queue_item extends DB_DataObject public $claimed; // datetime() /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Queue_item',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Queue_item',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/Remember_me.php b/classes/Remember_me.php index c84668c46b..9c86ebf020 100644 --- a/classes/Remember_me.php +++ b/classes/Remember_me.php @@ -2,9 +2,9 @@ /** * Table Definition for remember_me */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class Remember_me extends DB_DataObject +class Remember_me extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -15,7 +15,7 @@ class Remember_me extends DB_DataObject public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Remember_me',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Remember_me',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/Remote_profile.php b/classes/Remote_profile.php index e5613125dc..5afc85d209 100644 --- a/classes/Remote_profile.php +++ b/classes/Remote_profile.php @@ -22,9 +22,9 @@ if (!defined('LACONICA')) { exit(1); } /** * Table Definition for remote_profile */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class Remote_profile extends DB_DataObject +class Remote_profile extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -38,7 +38,7 @@ class Remote_profile extends DB_DataObject public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Remote_profile',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Remote_profile',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/Reply.php b/classes/Reply.php index 8e26f1684e..2c364ecaea 100644 --- a/classes/Reply.php +++ b/classes/Reply.php @@ -2,9 +2,9 @@ /** * Table Definition for reply */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class Reply extends DB_DataObject +class Reply extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -16,7 +16,7 @@ class Reply extends DB_DataObject public $replied_id; // int(4) /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Reply',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Reply',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/Sms_carrier.php b/classes/Sms_carrier.php index 26a88e3602..10ccb92837 100644 --- a/classes/Sms_carrier.php +++ b/classes/Sms_carrier.php @@ -2,9 +2,9 @@ /** * Table Definition for sms_carrier */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class Sms_carrier extends DB_DataObject +class Sms_carrier extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -17,7 +17,7 @@ class Sms_carrier extends DB_DataObject public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Sms_carrier',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Sms_carrier',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/Subscription.php b/classes/Subscription.php index 2a1037d2bc..cf6a3e57eb 100644 --- a/classes/Subscription.php +++ b/classes/Subscription.php @@ -22,9 +22,9 @@ if (!defined('LACONICA')) { exit(1); } /** * Table Definition for subscription */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class Subscription extends DB_DataObject +class Subscription extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -38,7 +38,7 @@ class Subscription extends DB_DataObject public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Subscription',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Subscription',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/Token.php b/classes/Token.php index a91b19f8e7..ef7ee20c06 100644 --- a/classes/Token.php +++ b/classes/Token.php @@ -2,9 +2,9 @@ /** * Table Definition for token */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class Token extends DB_DataObject +class Token extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -19,7 +19,7 @@ class Token extends DB_DataObject public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Token',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Token',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/User.php b/classes/User.php index 6430697822..ec57e52a97 100644 --- a/classes/User.php +++ b/classes/User.php @@ -27,11 +27,11 @@ define('WITHFRIENDS_CACHE_WINDOW', 61); /** * Table Definition for user */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; require_once 'Validate.php'; require_once(INSTALLDIR.'/lib/noticewrapper.php'); -class User extends DB_DataObject +class User extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -65,7 +65,7 @@ class User extends DB_DataObject public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('User',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('User',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE @@ -109,7 +109,12 @@ class User extends DB_DataObject } $qry = 'UPDATE ' . $table . ' SET ' . $toupdate . ' WHERE id = ' . $this->id; - return $this->query($qry); + $orig->decache(); + $result = $this->query($qry); + if ($result) { + $this->encache(); + } + return $result; } function allowed_nickname($nickname) { diff --git a/classes/User_openid.php b/classes/User_openid.php index 67f6f3b2ef..b65685ce79 100644 --- a/classes/User_openid.php +++ b/classes/User_openid.php @@ -2,9 +2,9 @@ /** * Table Definition for user_openid */ -require_once 'DB/DataObject.php'; +require_once 'classes/Memcached_DataObject.php'; -class User_openid extends DB_DataObject +class User_openid extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -17,7 +17,7 @@ class User_openid extends DB_DataObject public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('User_openid',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('User_openid',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE