October\Rain\Database\MemoryCache

Source: ~/vendor/october/rain/src/Database/MemoryCache.php

Query memory cache class.

Stores query results in memory to avoid running duplicate queries

Protected properties

protected array $cache

Cached results.

protected array $tableMap

The mapper between hashed keys and table names.

protected bool $enabled

Store enabled state.

protected static $instance

Public methods

public void __clone()

public void __wakeup()

public bool enabled($switch=NULL)

Check if the memory cache is enabled.

Parameters
  • $switch

public void flush()

Clear the memory cache.

public void forget($table $table)

Delete the cache for the given table.

Parameters
  • $table $table

public static void forgetInstance()

Forget this singleton's instance if it exists

public array|null get(QueryBuilder $query)

Get the cached results for the given query.

Parameters
  • QueryBuilder $query

public bool has(QueryBuilder $query)

Check if the given query is cached.

Parameters
  • QueryBuilder $query

public static void instance()

Create a new instance of this singleton.

public void put(QueryBuilder $query, array $results)

Store the results for the given query.

Parameters
  • QueryBuilder $query
  • array $results

Protected methods

protected void __construct()

Constructor.

protected string hash(QueryBuilder $query)

Calculate a hash key for the given query.

Parameters
  • QueryBuilder $query

protected void init()

Initialize the singleton free from constructor parameters.