public static function oneRecordCached($cacheKey, $query, $parameters = [], $errorHandler = null)
    {

        // check for cached record
        if (array_key_exists($cacheKey, static::$_record_cache)) {
            // return cache hit
            return static::$_record_cache[$cacheKey];
        }

        // preprocess and execute query
        $result = static::query($query, $parameters, $errorHandler);

        // get record
        $record = $result->fetch(PDO::FETCH_ASSOC);

        // save record to cache
        if ($cacheKey) {
            static::$_record_cache[$cacheKey] = $record;
        }

        // return record
        return $record;
    }
public static function oneRecordCached($cacheKey, $query, $parameters = [], $errorHandler = null)
    {

        // check for cached record
        if (array_key_exists($cacheKey, static::$_record_cache)) {
            // return cache hit
            return static::$_record_cache[$cacheKey];
        }

        // preprocess and execute query
        $result = static::query($query, $parameters, $errorHandler);

        // get record
        $record = $result->fetch(PDO::FETCH_ASSOC);

        // save record to cache
        if ($cacheKey) {
            static::$_record_cache[$cacheKey] = $record;
        }

        // return record
        return $record;
    }
public static function oneRecordCached ( $ cacheKey , $ query , $ parameters = [ ] , $ errorHandler = null ) { // check for cached record if ( array_key_exists ( $ cacheKey , static :: $ _record_cache ) ) { // return cache hit return static :: $ _record_cache [ $ cacheKey ] ; } // preprocess and execute query $ result = static :: query ( $ query , $ parameters , $ errorHandler ) ; // get record $ record = $ result -> fetch ( PDO :: FETCH_ASSOC ) ; // save record to cache if ( $ cacheKey ) { static :: $ _record_cache [ $ cacheKey ] = $ record ; } // return record return $ record ; }
Returns the first database record from a query with caching

It is recommended that you LIMIT 1 any records you want out of this to avoid having the database doing any work.

@param string $cacheKey A key for the cache to use for this query. If the key is found in the existing cache will return that instead of running the query.
@param string $query A MySQL query
@param array|string $parameters Optional parameters for vsprintf (array) or sprintf (string) to use for formatting the query.
@param callable $errorHandler A callback that will run in the event of an error instead of static::handleError
@return array Result from query or an empty array if nothing found.

@uses static::$_record_cache
Returns the first database record from a query with caching