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

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

Property Detail

$cacher protected

Cacher instance.

Type

\Psr\SimpleCache\CacheInterface

$collection protected

The decorated schema collection

Type

\Cake\Database\Schema\CollectionInterface

$prefix protected

The cache key prefix

Type

string

© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.1/class-Cake.Database.Schema.CachedCollection.html