Back to OutputController class

Method get

public mixed
get
(mixed $id, mixed $group = null)
Get stored cached data by ID and group
Parameters
  • string $id The cache data ID
  • string $group The cache data group
Returns
  • mixed Boolean false on no result, cached object otherwise
Since
  • 1.7.0

Method get - Source code

/**
 * Get stored cached data by ID and group
 *
 * @param   string  $id     The cache data ID
 * @param   string  $group  The cache data group
 *
 * @return  mixed  Boolean false on no result, cached object otherwise
 *
 * @since   1.7.0
 */
public function get($id, $group = null)
{
    $data = $this->cache->get($id, $group);
    if ($data === false) {
        $locktest = $this->cache->lock($id, $group);
        // If locklooped is true try to get the cached data again; it could exist now.
        if ($locktest->locked === true && $locktest->locklooped === true) {
            $data = $this->cache->get($id, $group);
        }
        if ($locktest->locked === true) {
            $this->cache->unlock($id, $group);
        }
    }
    // Check again because we might get it from second attempt
    if ($data !== false) {
        // Trim to fix unserialize errors
        $data = unserialize(trim($data));
    }
    return $data;
}