[Memcached_DataObject] Change how multiGet achieves an ordered result

The previous approach sent the key values twice, which for large sets is
twice as bad.

As an optional feature of this approach multiGet now allows retrieving tuples
in exact order and amount of the requested key values.
This commit is contained in:
Alexei Sorokin
2020-09-03 18:11:12 +03:00
parent 55136c1c6f
commit 4884a97223
2 changed files with 132 additions and 78 deletions

View File

@@ -75,15 +75,25 @@ abstract class Managed_DataObject extends Memcached_DataObject
/**
* Get multiple items from the database by key
*
* @param string $keyCol name of column for key
* @param array $keyVals key values to fetch
* @param boolean $skipNulls return only non-null results?
*
* @return array Array of objects, in order
* @param string $keyCol name of column for key
* @param array $keyVals key values to fetch
* @param bool $skipNulls return only non-null results
* @param bool $preserve return the same tuples as input
* @return object An object with tuples to be fetched, in order
*/
public static function multiGet($keyCol, array $keyVals, $skipNulls = true)
{
return parent::multiGetClass(get_called_class(), $keyCol, $keyVals, $skipNulls);
public static function multiGet(
string $keyCol,
array $keyVals,
bool $skipNulls = true,
bool $preserve = false
): object {
return parent::multiGetClass(
get_called_class(),
$keyCol,
$keyVals,
$skipNulls,
$preserve
);
}
/**
@@ -312,11 +322,6 @@ abstract class Managed_DataObject extends Memcached_DataObject
return $ckeys;
}
public function escapedTableName()
{
return common_database_tablename($this->tableName());
}
/**
* Returns an object by looking at the primary key column(s).
*