Documentation

PdoAdapter extends AbstractAdapter
in package
implements PruneableInterface

Interfaces, Classes and Traits

PruneableInterface
Interface extends psr-6 and psr-16 caches to allow for pruning (deletion) of all expired cache items.

Table of Contents

$maxIdLength  : mixed
$apcuSupported  : mixed
$conn  : mixed
$connectionOptions  : mixed
$dataCol  : mixed
$dbalAdapter  : mixed
$driver  : mixed
$dsn  : mixed
$idCol  : mixed
$lifetimeCol  : mixed
$marshaller  : mixed
$namespace  : mixed
$password  : mixed
$phpFilesSupported  : mixed
$serverVersion  : mixed
$table  : mixed
$timeCol  : mixed
$username  : mixed
__construct()  : mixed
You can either pass an existing database connection as PDO instance or a DSN string that will be used to lazy-connect to the database when the cache is actually used.
clear()  : mixed
{@inheritDoc}
commit()  : bool
{@inheritdoc}
configureSchema()  : void
Adds the Table to the Schema if the adapter uses this Connection.
createConnection()  : mixed
createSystemCache()  : AdapterInterface
Returns the best possible adapter that your runtime supports.
createTable()  : mixed
Creates the table to store cache items which can be called once for setup.
delete()  : bool
{@inheritDoc}
deleteItem()  : mixed
{@inheritDoc}
deleteItems()  : mixed
{@inheritDoc}
get()  : mixed
{@inheritDoc}
getItem()  : mixed
{@inheritDoc}
getItems()  : mixed
{@inheritDoc}
hasItem()  : mixed
{@inheritDoc}
prune()  : bool
reset()  : mixed
{@inheritDoc}
save()  : mixed
{@inheritDoc}
saveDeferred()  : mixed
{@inheritDoc}
setLogger()  : void
{@inheritDoc}
doClear()  : mixed
{@inheritdoc}
doDelete()  : mixed
{@inheritdoc}
doFetch()  : mixed
{@inheritdoc}
doHave()  : mixed
{@inheritdoc}
doSave()  : mixed
{@inheritdoc}
getConnection()  : PDO
getServerVersion()  : string
isTableMissing()  : bool

Properties

$connectionOptions

private mixed $connectionOptions = []

$lifetimeCol

private mixed $lifetimeCol = 'item_lifetime'

Methods

__construct()

You can either pass an existing database connection as PDO instance or a DSN string that will be used to lazy-connect to the database when the cache is actually used.

public __construct(PDO|string $connOrDsn[, string $namespace = '' ], int $defaultLifetime[, array<string|int, mixed> $options = [] ][, MarshallerInterface|null $marshaller = null ]) : mixed

List of available options:

  • db_table: The name of the table [default: cache_items]
  • db_id_col: The column where to store the cache id [default: item_id]
  • db_data_col: The column where to store the cache data [default: item_data]
  • db_lifetime_col: The column where to store the lifetime [default: item_lifetime]
  • db_time_col: The column where to store the timestamp [default: item_time]
  • db_username: The username when lazy-connect [default: '']
  • db_password: The password when lazy-connect [default: '']
  • db_connection_options: An array of driver-specific connection options [default: []]
Parameters
$connOrDsn : PDO|string
$namespace : string = ''
$defaultLifetime : int
$options : array<string|int, mixed> = []
$marshaller : MarshallerInterface|null = null
Tags
throws
InvalidArgumentException

When first argument is not PDO nor Connection nor string

throws
InvalidArgumentException

When PDO error mode is not PDO::ERRMODE_EXCEPTION

throws
InvalidArgumentException

When namespace contains invalid characters

Return values
mixed

clear()

{@inheritDoc}

public clear([string $prefix = '' ]) : mixed
Parameters
$prefix : string = ''
Return values
mixed

commit()

{@inheritdoc}

public commit() : bool
Return values
bool

configureSchema()

Adds the Table to the Schema if the adapter uses this Connection.

public configureSchema(Schema $schema, Connection $forConnection) : void
Parameters
$schema : Schema
$forConnection : Connection
Tags
deprecated

since symfony/cache 5.4 use DoctrineDbalAdapter instead

Return values
void

createConnection()

public static createConnection(string $dsn[, array<string|int, mixed> $options = [] ]) : mixed
Parameters
$dsn : string
$options : array<string|int, mixed> = []
Return values
mixed

createSystemCache()

Returns the best possible adapter that your runtime supports.

public static createSystemCache(string $namespace, int $defaultLifetime, string $version, string $directory[, LoggerInterface|null $logger = null ]) : AdapterInterface

Using ApcuAdapter makes system caches compatible with read-only filesystems.

Parameters
$namespace : string
$defaultLifetime : int
$version : string
$directory : string
$logger : LoggerInterface|null = null
Return values
AdapterInterface

createTable()

Creates the table to store cache items which can be called once for setup.

public createTable() : mixed

Cache ID are saved in a column of maximum length 255. Cache data is saved in a BLOB.

Tags
throws
PDOException

When the table already exists

throws
DomainException

When an unsupported PDO driver is used

Return values
mixed

delete()

{@inheritDoc}

public delete(string $key) : bool
Parameters
$key : string
Return values
bool

deleteItem()

{@inheritDoc}

public deleteItem(mixed $key) : mixed
Parameters
$key : mixed
Return values
mixed

deleteItems()

{@inheritDoc}

public deleteItems(array<string|int, mixed> $keys) : mixed
Parameters
$keys : array<string|int, mixed>
Return values
mixed

get()

{@inheritDoc}

public get(string $key, callable $callback[, float|null $beta = null ][, array<string|int, mixed>|null &$metadata = null ]) : mixed
Parameters
$key : string
$callback : callable
$beta : float|null = null
$metadata : array<string|int, mixed>|null = null
Return values
mixed

getItem()

{@inheritDoc}

public getItem(mixed $key) : mixed
Parameters
$key : mixed
Return values
mixed

getItems()

{@inheritDoc}

public getItems([array<string|int, mixed> $keys = [] ]) : mixed
Parameters
$keys : array<string|int, mixed> = []
Return values
mixed

hasItem()

{@inheritDoc}

public hasItem(mixed $key) : mixed
Parameters
$key : mixed
Return values
mixed

prune()

public prune() : bool
Return values
bool

reset()

{@inheritDoc}

public reset() : mixed
Return values
mixed

doClear()

{@inheritdoc}

protected doClear(string $namespace) : mixed
Parameters
$namespace : string
Return values
mixed

doDelete()

{@inheritdoc}

protected doDelete(array<string|int, mixed> $ids) : mixed
Parameters
$ids : array<string|int, mixed>
Return values
mixed

doFetch()

{@inheritdoc}

protected doFetch(array<string|int, mixed> $ids) : mixed
Parameters
$ids : array<string|int, mixed>
Return values
mixed

doHave()

{@inheritdoc}

protected doHave(string $id) : mixed
Parameters
$id : string
Return values
mixed

doSave()

{@inheritdoc}

protected doSave(array<string|int, mixed> $values, int $lifetime) : mixed
Parameters
$values : array<string|int, mixed>
$lifetime : int
Return values
mixed

getConnection()

private getConnection() : PDO
Return values
PDO

getServerVersion()

private getServerVersion() : string
Return values
string

isTableMissing()

private isTableMissing(PDOException $exception) : bool
Parameters
$exception : PDOException
Return values
bool

Search results