pkeyGet is now static and more similar to getKV

Memcached_DataObject now defines
   * pkeyGetClass to avoid collision with Managed_DataObject pkeyGet
   * getClassKV to avoid collision with Managed_DataObject getKV
This commit is contained in:
Mikael Nordfeldth
2013-08-18 15:42:51 +02:00
parent 1710a619a8
commit 861e838add
40 changed files with 31 additions and 347 deletions

View File

@@ -118,18 +118,6 @@ class Fave_tally extends Managed_DataObject
return array(false, false, false);
}
/**
* Get a single object with multiple keys
*
* @param array $kv Map of key-value pairs
*
* @return User_flag_profile found object or null
*/
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Fave_tally', $kv);
}
/**
* Increment a notice's tally
*

View File

@@ -56,19 +56,6 @@ class RSVP extends Managed_DataObject
public $response; // tinyint
public $created; // datetime
/**
* Get an instance by compound key
*
* @param array $kv array of key-value mappings
*
* @return Bookmark object found, or null for no hits
*/
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('RSVP', $kv);
}
/**
* Add the compound profile_id/event_id index to our cache keys
* since the DB_DataObject stuff doesn't understand compound keys

View File

@@ -69,23 +69,6 @@ class Profile_detail extends Managed_DataObject
public $created;
public $modified;
/**
* Get an instance by compound key
*
* This is a utility method to get a single instance with a given set of
* key-value pairs. Usually used for the primary key for a compound key; thus
* the name.
*
* @param array $kv array of key-value mappings
*
* @return Bookmark object found, or null for no hits
*
*/
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Profile_detail', $kv);
}
static function schemaDef()
{
return array(

View File

@@ -55,19 +55,6 @@ class ModLog extends Managed_DataObject
public $grant; // 1 = grant, 0 = revoke
public $created; // datetime
/**
* Get an instance by compound key
*
* @param array $kv array of key-value mappings
*
* @return TagSub object found, or null for no hits
*
*/
function pkeyGet($kv)
{
return Managed_DataObject::pkeyGet('ModLog', $kv);
}
/**
* The One True Thingy that must be defined and declared.
*/

View File

@@ -21,11 +21,6 @@ class User_openid_trustroot extends Managed_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('User_openid_trustroot', $kv);
}
function table()
{
$db = $this->getDatabaseConnection();

View File

@@ -53,23 +53,6 @@ class Poll extends Managed_DataObject
public $options; // text; newline(?)-delimited
public $created; // datetime
/**
* Get an instance by compound key
*
* This is a utility method to get a single instance with a given set of
* key-value pairs. Usually used for the primary key for a compound key; thus
* the name.
*
* @param array $kv array of key-value mappings
*
* @return Bookmark object found, or null for no hits
*
*/
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Poll', $kv);
}
/**
* The One True Thingy that must be defined and declared.
*/

View File

@@ -52,23 +52,6 @@ class Poll_response extends Managed_DataObject
public $selection; // int -> choice #
public $created; // datetime
/**
* Get an instance by compound key
*
* This is a utility method to get a single instance with a given set of
* key-value pairs. Usually used for the primary key for a compound key; thus
* the name.
*
* @param array $kv array of key-value mappings
*
* @return Bookmark object found, or null for no hits
*
*/
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Poll_response', $kv);
}
/**
* The One True Thingy that must be defined and declared.
*/

View File

@@ -55,23 +55,6 @@ class QnA_Answer extends Managed_DataObject
public $content; // text -> response text
public $created; // datetime
/**
* Get an instance by compound key
*
* This is a utility method to get a single instance with a given set of
* key-value pairs. Usually used for the primary key for a compound key; thus
* the name.
*
* @param array $kv array of key-value mappings
*
* @return QA_Answer object found, or null for no hits
*
*/
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('QnA_Answer', $kv);
}
/**
* The One True Thingy that must be defined and declared.
*/

View File

@@ -55,23 +55,6 @@ class QnA_Question extends Managed_DataObject
public $closed; // int (boolean) whether a question is closed
public $created; // datetime
/**
* Get an instance by compound key
*
* This is a utility method to get a single instance with a given set of
* key-value pairs. Usually used for the primary key for a compound key; thus
* the name.
*
* @param array $kv array of key-value mappings
*
* @return Bookmark object found, or null for no hits
*
*/
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('QnA_Question', $kv);
}
/**
* The One True Thingy that must be defined and declared.
*/

View File

@@ -55,23 +55,6 @@ class QnA_Vote extends Managed_DataObject
public $profile_id; // int -> question.id
public $created; // datetime
/**
* Get an instance by compound key
*
* This is a utility method to get a single instance with a given set of
* key-value pairs. Usually used for the primary key for a compound key; thus
* the name.
*
* @param array $kv array of key-value mappings
*
* @return QnA_Vote object found, or null for no hits
*
*/
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('QnA_Vote', $kv);
}
/**
* The One True Thingy that must be defined and declared.
*/

View File

@@ -61,18 +61,6 @@ class Realtime_channel extends Managed_DataObject
public $created; // created date
public $modified; // modified date
/**
* Get an instance by compound key
*
* @param array $kv array of key-value mappings
*
* @return Realtime_channel object found, or null for no hits
*/
function pkeyGet($kv)
{
return Managed_DataObject::pkeyGet('Realtime_channel', $kv);
}
/**
* The One True Thingy that must be defined and declared.
*/

View File

@@ -50,23 +50,6 @@ class SearchSub extends Managed_DataObject
public $profile_id; // int -> profile.id
public $created; // datetime
/**
* Get an instance by compound key
*
* This is a utility method to get a single instance with a given set of
* key-value pairs. Usually used for the primary key for a compound key; thus
* the name.
*
* @param array $kv array of key-value mappings
*
* @return SearchSub object found, or null for no hits
*
*/
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('SearchSub', $kv);
}
/**
* The One True Thingy that must be defined and declared.
*/

View File

@@ -204,11 +204,6 @@ class SubMirror extends Managed_DataObject
return $saved;
}
public /*static*/ function pkeyGet($v)
{
return parent::pkeyGet(__CLASS__, $v);
}
/**
* Get the mirroring setting for a pair of profiles, if existing.
*

View File

@@ -49,23 +49,6 @@ class TagSub extends Managed_DataObject
public $profile_id; // int -> profile.id
public $created; // datetime
/**
* Get an instance by compound key
*
* This is a utility method to get a single instance with a given set of
* key-value pairs. Usually used for the primary key for a compound key; thus
* the name.
*
* @param array $kv array of key-value mappings
*
* @return TagSub object found, or null for no hits
*
*/
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('TagSub', $kv);
}
/**
* The One True Thingy that must be defined and declared.
*/

View File

@@ -57,32 +57,6 @@ class Twitter_synch_status extends Managed_DataObject
public $created; // datetime not_null
public $modified; // datetime not_null
/**
* Get an instance by key
*
* @param string $k Key to use to lookup (usually 'foreign_id' for this class)
* @param mixed $v Value to lookup
*
* @return Twitter_synch_status object found, or null for no hits
*/
static function staticGet($k, $v=null)
{
throw new Exception("Use pkeyGet() for this class.");
}
/**
* Get an instance by compound primary key
*
* @param array $kv key-value pair array
*
* @return Twitter_synch_status object found, or null for no hits
*
*/
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Twitter_synch_status', $kv);
}
/**
* return table definition for DB_DataObject
*

View File

@@ -108,18 +108,6 @@ class User_flag_profile extends Managed_DataObject
return array(false, false, false);
}
/**
* Get a single object with multiple keys
*
* @param array $kv Map of key-value pairs
*
* @return User_flag_profile found object or null
*/
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('User_flag_profile', $kv);
}
/**
* Check if a flag exists for given profile and user
*

View File

@@ -133,13 +133,13 @@ class Yammer_common extends Managed_DataObject
*/
protected static function doRecord($class, $field, $orig_id, $local_id)
{
$map = Memcached_DataObject::staticGet($class, 'id', $orig_id);
$map = Memcached_DataObject::getClassKV($class, 'id', $orig_id);
if (!empty($map)) {
return $map;
}
$map = Memcached_DataObject::staticGet($class, $field, $local_id);
$map = Memcached_DataObject::getClassKV($class, $field, $local_id);
if (!empty($map)) {
return $map;