MemoryCache

Query memory cache class.

 class Winter\Storm\Database\MemoryCache

Stores query results in memory to avoid running duplicate queries

Traits

Trait Description
Singleton

Singleton trait.

Properties

protected $cache : array

Cached results.

protected $enabled : bool

Store enabled state.

protected $tableMap : array

The mapper between hashed keys and table names.

Methods

public enabled ($switch = null) : bool

Check if the memory cache is enabled.

Parameters
Property Description
$switch
mixed
Returns
bool

public flush () : void

Clear the memory cache.

Returns
void

public forget (string $table) : void

Delete the cache for the given table.

Parameters
Property Description
$table
string
Returns
void

public get (Winter\Storm\Database\QueryBuilder $query) : array | null

Get the cached results for the given query.

Parameters
Property Description
$query
Winter\Storm\Database\QueryBuilder
Returns
array | null

public has (Winter\Storm\Database\QueryBuilder $query) : bool

Check if the given query is cached.

Parameters
Property Description
$query
Winter\Storm\Database\QueryBuilder
Returns
bool

public put (Winter\Storm\Database\QueryBuilder $query, array $results) : void

Store the results for the given query.

Parameters
Property Description
$query
Winter\Storm\Database\QueryBuilder
$results
array
Returns
void

protected hash (Winter\Storm\Database\QueryBuilder $query) : string

Calculate a hash key for the given query.

Parameters
Property Description
$query
Winter\Storm\Database\QueryBuilder
Returns
string

inherited public __clone ()

Inherited from Singleton
Returns
mixed

inherited public __wakeup ()

Inherited from Singleton
Returns
mixed

inherited public static final forgetInstance ($container = null) : void

Inherited from Singleton

Forget this singleton's instance if it exists

Parameters
Property Description
$container
mixed
Returns
void

inherited public static final instance ($container = null) : static

Inherited from Singleton

Create a new instance of this singleton.

Parameters
Property Description
$container
mixed
Returns
static

inherited protected final __construct ()

Inherited from Singleton

Constructor.

Returns
mixed

inherited protected init ()

Inherited from Singleton

Initialize the singleton free from constructor parameters.

Returns
mixed
Copyright © 2024 Winter CMS