try to use caching functions where possible in User
darcs-hash:20081002162513-5ed1f-fff718be660fa4a8abf58df402a3db30d72d11db.gz
This commit is contained in:
parent
c8392ed58d
commit
37735a35c0
|
@ -30,4 +30,8 @@ class Fave extends Memcached_DataObject
|
||||||
}
|
}
|
||||||
return $fave;
|
return $fave;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function &pkeyGet($kv) {
|
||||||
|
return Memcached_DataObject('Fave', $kv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,4 +42,8 @@ class Subscription extends Memcached_DataObject
|
||||||
|
|
||||||
/* the code above is auto generated do not remove the tag below */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
|
|
||||||
|
function &pkeyGet($kv) {
|
||||||
|
return Memcached_DataObject::pkeyGet('Subscription', $kv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,21 +65,15 @@ class User extends Memcached_DataObject
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
|
|
||||||
function getProfile() {
|
function getProfile() {
|
||||||
$profile = DB_DataObject::factory('profile');
|
return Profile::staticGet('id', $this->id);
|
||||||
$profile->id = $this->id;
|
|
||||||
if ($profile->find()) {
|
|
||||||
$profile->fetch();
|
|
||||||
return $profile;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isSubscribed($other) {
|
function isSubscribed($other) {
|
||||||
assert(!is_null($other));
|
assert(!is_null($other));
|
||||||
$sub = DB_DataObject::factory('subscription');
|
# XXX: cache results of this query
|
||||||
$sub->subscriber = $this->id;
|
$sub = Subscription::pkeyGet(array('subscriber' => $this->id,
|
||||||
$sub->subscribed = $other->id;
|
'subscribed' => $other->id));
|
||||||
return $sub->find();
|
return (is_null($sub)) ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
# 'update' won't write key columns, so we have to do it ourselves.
|
# 'update' won't write key columns, so we have to do it ourselves.
|
||||||
|
@ -130,7 +124,7 @@ class User extends Memcached_DataObject
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCarrier() {
|
function getCarrier() {
|
||||||
return Sms_carrier::staticGet($this->carrier);
|
return Sms_carrier::staticGet('id', $this->carrier);
|
||||||
}
|
}
|
||||||
|
|
||||||
function subscribeTo($other) {
|
function subscribeTo($other) {
|
||||||
|
@ -271,10 +265,9 @@ class User extends Memcached_DataObject
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasFave($notice) {
|
function hasFave($notice) {
|
||||||
$fave = new Fave();
|
$fave = Fave::pkeyGet(array('user_id' => $this->id,
|
||||||
$fave->user_id = $this->id;
|
'notice_id' => $notice->id));
|
||||||
$fave->notice_id = $notice->id;
|
if (!is_null($fave)) {
|
||||||
if ($fave->find()) {
|
|
||||||
$result = true;
|
$result = true;
|
||||||
} else {
|
} else {
|
||||||
$result = false;
|
$result = false;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user