Gets data for a particular table, or all tables.
string|null $key: The key of the cache entry to retrieve. Defaults to NULL, this will return all table data.
array $data An array of table data.
public function get($key = NULL) {
if ($key) {
if (!isset($this->storage[$key])) {
// Prepare a cache ID.
$cid = $this->baseCid . ':' . $key;
$from_cache = FALSE;
if ($data = $this
->cacheGet($cid)) {
$this->storage[$key] = $data->data;
$from_cache = TRUE;
}
elseif (!$this->fullyLoaded) {
$this->storage = $this
->getData();
}
if (!$from_cache) {
if (!isset($this->storage[$key])) {
// Write an empty cache entry if no information for that table
// exists to avoid repeated cache get calls for this table and
// prevent loading all tables unnecessarily.
$this->storage[$key] = array();
}
// Create a cache entry for the requested table.
$this->cacheBackend
->set($this
->prepareCid($cid), $this->storage[$key]);
}
}
if (isset($this->storage[$key])) {
return $this->storage[$key];
}
// If the key is invalid, return an empty array.
return array();
}
else {
if (!$this->fullyLoaded) {
$this->storage = $this
->getData();
}
}
return $this->storage;
}