PdoAdapter
class PdoAdapter extends AbstractAdapter implements PruneableInterface
Traits
Properties
protected | $maxIdLength |
Methods
Persists several cache items immediately.
Like the native unserialize() function but throws an exception if anything goes wrong.
{@inheritdoc}
Wraps the callback passed to ->get() in a callable.
You can either pass an existing database connection as PDO instance or a Doctrine DBAL Connection or a DSN string that will be used to lazy-connect to the database when the cache is actually used.
Returns an ApcuAdapter if supported, a PhpFilesAdapter otherwise.
Creates the table to store cache items which can be called once for setup.
Details
abstract protected array|bool
doSave(array $values, int $lifetime)
Persists several cache items immediately.
bool
enableVersioning(bool $enable = true)
Enables/disables versioning of items.
When versioning is enabled, clearing the cache is atomic and doesn't require listing existing keys to proceed, but old keys may need garbage collection and extra round-trips to the back-end are required.
Calling this method also clears the memoized namespace version and thus forces a resynchonization of it.
static protected mixed
unserialize(string $value)
deprecated
deprecated since Symfony 4.2, use DefaultMarshaller instead.
Like the native unserialize() function but throws an exception if anything goes wrong.
callable
setCallbackWrapper(callable|null $callbackWrapper)
Wraps the callback passed to ->get() in a callable.
__construct($connOrDsn, string $namespace = '', int $defaultLifetime = 0, array $options = array(), MarshallerInterface $marshaller = null)
You can either pass an existing database connection as PDO instance or a Doctrine DBAL Connection or a DSN string that will be used to lazy-connect to the database when the cache is actually used.
When a Doctrine DBAL Connection is passed, the cache table is created automatically when possible. Otherwise, use the createTable() method.
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: array()]
static AdapterInterface
createSystemCache(string $namespace, int $defaultLifetime, string $version, string $directory, LoggerInterface $logger = null)
Returns an ApcuAdapter if supported, a PhpFilesAdapter otherwise.
Using ApcuAdapter makes system caches compatible with read-only filesystems.