MemoryCache stores query results in memory to avoid running duplicate queries

Protected properties

protected array $cache

cache results

protected array $tableMap

tableMap between hashed keys and table names

protected bool $enabled

enabled store enabled state

protected static $instance

Public methods

public void __clone()

public void __wakeup()

public bool enabled($switch=NULL)

enabled checks if the memory cache is enabled

  • $switch

public void flush()

flush clears the memory cache

public void forget($table $table)

forget deletes the cache for the given table

  • $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.

  • QueryBuilder $query

public bool has(QueryBuilder $query)

has checks if the given query is cached

  • QueryBuilder $query

public static void instance()

Create a new instance of this singleton.

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

put stores the results for the given query

  • QueryBuilder $query
  • array $results

Protected methods

protected void __construct()


protected string hash(QueryBuilder $query)

hash calculates a hash key for the given query

  • QueryBuilder $query

protected void init()

Initialize the singleton free from constructor parameters.