Class CachedCollection
Decorates a schema collection and adds caching
Properties summary
-
$cacher protected
\Psr\SimpleCache\CacheInterface
Cacher instance.
-
$collection protected
\Cake\Database\Schema\CollectionInterface
The decorated schema collection
-
$prefix protected
string
The cache key prefix
Method Summary
-
__construct() public
Constructor.
-
cacheKey() public
Get the cache key for a given name.
-
describe() public
Get the column metadata for a table.
-
getCacher() public
Get a cacher.
-
listTables() public
Get the list of tables available in the current connection.
-
setCacher() public
Set a cacher.
Method Detail
__construct() public ¶
__construct(\Cake\Database\Schema\CollectionInterface $collection, string $prefix, \Psr\SimpleCache\CacheInterface $cacher)
Constructor.
Parameters
-
\Cake\Database\Schema\CollectionInterface
$collection The collection to wrap.
-
string
$prefix The cache key prefix to use. Typically the connection name.
-
\Psr\SimpleCache\CacheInterface
$cacher Cacher instance.
cacheKey() public ¶
cacheKey(string $name)
Get the cache key for a given name.
Parameters
-
string
$name The name to get a cache key for.
Returns
string
The cache key.
describe() public ¶
describe(string $name, array $options)
Get the column metadata for a table.
Caching will be applied if cacheMetadata
key is present in the Connection
configuration options. Defaults to _cakemodel when true.
Options
forceRefresh
- Set to true to force rebuilding the cached metadata. Defaults to false.
Parameters
-
string
$name The name of the table to describe.
-
array
$options optional The options to use, see above.
Returns
\Cake\Database\Schema\TableSchemaInterface
Object with column metadata.
Throws
Cake\Database\Exception
when table cannot be described.
getCacher() public ¶
getCacher()
Get a cacher.
Returns
\Psr\SimpleCache\CacheInterface
$cacher Cacher object
listTables() public ¶
listTables()
Get the list of tables available in the current connection.
Returns
string[]
The list of tables in the connected database/schema.
setCacher() public ¶
setCacher(\Psr\SimpleCache\CacheInterface $cacher)
Set a cacher.
Parameters
-
\Psr\SimpleCache\CacheInterface
$cacher Cacher object
Returns
$this