Class CachedCollection

Extends the schema collection class to provide caching

Properties summary

  • $_cache protected
    string|bool

    The name of the cache config key to use for caching table metadata, of false if disabled.

  • $_connection protected
    \Cake\Database\Connection

    Connection object

  • $_dialect protected
    \Cake\Database\Schema\BaseSchema

    Schema dialect instance.

Method Summary

  • __construct() public

    Constructor.

  • _reflect() protected

    Helper method for running each step of the reflection process.

  • cacheKey() public

    Get the cache key for a given name.

  • cacheMetadata() public

    Sets the cache config name to use for caching table metadata, or disables it if false is passed.

  • describe() public

    Get the column metadata for a table.

  • getCacheMetadata() public

    Gets the cache config name to use for caching table metadata, false means disabled.

  • listTables() public

    Get the list of tables available in the current connection.

  • setCacheMetadata() public

    Sets the cache config name to use for caching table metadata, or disables it if false is passed.

Method Detail

__construct() public

__construct(\Cake\Datasource\ConnectionInterface $connection, mixed $cacheKey)

Constructor.

Parameters

\Cake\Datasource\ConnectionInterface $connection

The connection instance.

string|bool $cacheKey optional

The cache key or boolean false to disable caching.

_reflect() protected

_reflect(mixed $stage, mixed $name, mixed $config, mixed $schema)

Helper method for running each step of the reflection process.

Parameters

string $stage

The stage name.

string $name

The table name.

array $config

The config data.

\Cake\Database\Schema\TableSchemaInterface $schema

The table schema instance.

Throws

Cake\Database\Exception
on query failure.

cacheKey() public

cacheKey(mixed $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.

cacheMetadata() public

cacheMetadata(mixed $enable)

Sets the cache config name to use for caching table metadata, or disables it if false is passed.

If called with no arguments it returns the current configuration name.

Parameters

bool|null $enable optional

Whether or not to enable caching

Returns

string|bool

describe() public

describe(mixed $name, array $options)

Get the column metadata for a table.

The name can include a database schema name in the form 'schema.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\TableSchema

Object with column metadata.

Throws

Cake\Database\Exception
when table cannot be described.

getCacheMetadata() public

getCacheMetadata()

Gets the cache config name to use for caching table metadata, false means disabled.

Returns

string|bool

listTables() public

listTables()

Get the list of tables available in the current connection.

Returns

string[]

The list of tables in the connected database/schema.

setCacheMetadata() public

setCacheMetadata(mixed $enable)

Sets the cache config name to use for caching table metadata, or disables it if false is passed.

Parameters

bool $enable

Whether or not to enable caching

Returns

$this

Property Detail

$_cache protected

The name of the cache config key to use for caching table metadata, of false if disabled.

Type

string|bool

$_connection protected

Connection object

Type

\Cake\Database\Connection

$_dialect protected

Schema dialect instance.

Type

\Cake\Database\Schema\BaseSchema

© 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/3.9/class-Cake.Database.Schema.CachedCollection.html