MemoryCache
class MemoryCache
Query memory cache class.
Stores query results in memory to avoid running duplicate queries
Adapted from october\rain\database\MemoryCache
Traits
Singleton trait.
Properties
static protected | $instance | from Singleton | |
protected array | $cache | Cached results. |
|
protected array | $tableMap | The mapper between hashed keys and table names. |
|
protected bool | $enabled |
Methods
Check if the memory cache is enabled.
Delete the cache for the given table.
Clear the memory cache.
Details
in
Singleton at line 18
final static
instance()
Create a new instance of this singleton.
in
Singleton at line 28
final static
forgetInstance()
Forget this singleton's instance if it exists
in
Singleton at line 36
final protected
__construct()
Constructor.
in
Singleton at line 44
protected
initialize()
Initialize the singleton free from constructor parameters.
in
Singleton at line 48
__clone()
No description
in
Singleton at line 53
__wakeup()
No description
at line 43
bool
enabled($switch = null)
Check if the memory cache is enabled.
at line 58
bool
has(Builder $query)
Check if the given query is cached.
at line 69
array|null
get(Builder $query)
Get the cached results for the given query.
at line 85
void
put(Builder $query, array $results)
Store the results for the given query.
at line 104
void
forget(string $table)
Delete the cache for the given table.
at line 121
void
flush()
Clear the memory cache.
at line 133
protected string
hash(Builder $query)
Calculate a hash key for the given query.