PdoBackend
class PdoBackend extends AbstractBackend implements TaggableBackendInterface, IterableBackendInterface, PhpCapableBackendInterface, WithSetupInterface, WithStatusInterface (View source)
A PDO database cache backend
Traits
Constants
DATETIME_EXPIRYTIME_UNLIMITED |
|
UNLIMITED_LIFETIME |
|
Properties
protected FrontendInterface | $cache | Reference to the cache frontend which uses this backend |
from AbstractBackend |
protected string | $cacheIdentifier | from AbstractBackend | |
protected string | $identifierPrefix | A prefix to seperate stored by appliaction context and cache |
from AbstractBackend |
protected int | $defaultLifetime | Default lifetime of a cache entry in seconds |
from AbstractBackend |
protected EnvironmentConfiguration | $environmentConfiguration | from AbstractBackend | |
protected array | $_requiredEntryIdentifiers | from RequireOnceFromValueTrait | |
protected string | $dataSourceName | ||
protected string | $username | ||
protected string | $password | ||
protected array | $driverOptions | ||
protected PDO | $databaseHandle | ||
protected string | $pdoDriver | ||
protected string | $context | ||
protected string | $cacheTableName | ||
protected string | $tagsTableName | ||
protected ArrayIterator|null | $cacheEntriesIterator |
Methods
Constructs this backend
No description
Sets the default lifetime for this cache backend
Calculates the expiry time by the given lifetime. If no lifetime is specified, the default lifetime is used.
Returns the internally used, prefixed entry identifier for the given public entry identifier.
Loads PHP code from the cache and require_onces it right away.
Sets the DSN to use
Sets the username to use
Sets the password to use
Sets the driverOptions to use
Sets the name of the "cache" table
Sets the name of the "tags" table
Saves data in the cache.
Loads data from the cache.
Checks if a cache entry with the specified identifier exists.
Removes all cache entries matching the specified identifier.
Removes all cache entries of this cache.
Removes all cache entries of this cache which are tagged by the specified tag.
Finds and returns all cache entry identifiers which are tagged by the specified tag.
Does garbage collection
Returns an SQL statement that evaluates to true if the entry is not expired.
Connect to the database
Creates the tables needed for the cache backend.
Returns the data of the current cache entry pointed to by the cache entry iterator.
Move forward to the next cache entry.
Returns the identifier of the current cache entry pointed to by the cache entry iterator.
Checks if the current position of the cache entry iterator is valid.
Rewinds the cache entry iterator to the first element and fetches cacheEntries.
No description
Details
__construct(EnvironmentConfiguration $environmentConfiguration = null, array $options = [])
Constructs this backend
protected void
setProperties(array $properties, bool $throwExceptionIfPropertyNotSettable = true)
No description
protected bool
setProperty(string $propertyName, mixed $propertyValue)
No description
void
setCache(FrontendInterface $cache)
Sets a reference to the cache frontend which uses this backend
void
setDefaultLifetime(int|string $defaultLifetime)
Sets the default lifetime for this cache backend
protected DateTime
calculateExpiryTime(int $lifetime = null)
Calculates the expiry time by the given lifetime. If no lifetime is specified, the default lifetime is used.
string
getPrefixedIdentifier(string $entryIdentifier)
Returns the internally used, prefixed entry identifier for the given public entry identifier.
While Flow applications will mostly refer to the simple entry identifier, it may be necessary to know the actual identifier used by the cache backend in order to share cache entries with other applications. This method allows for retrieving it.
Note that, in case of the AbstractBackend, this method is returns just the given entry identifier.
mixed
requireOnce(string $entryIdentifier)
Loads PHP code from the cache and require_onces it right away.
protected void
setDataSourceName(string $DSN)
Sets the DSN to use
protected void
setUsername(string $username)
Sets the username to use
protected void
setPassword(string $password)
Sets the password to use
protected void
setDriverOptions(array $driverOptions)
Sets the driverOptions to use
protected void
setCacheTableName(string $cacheTableName)
Sets the name of the "cache" table
protected void
setTagsTableName(string $tagsTableName)
Sets the name of the "tags" table
void
set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null)
Saves data in the cache.
mixed
get(string $entryIdentifier)
Loads data from the cache.
bool
has(string $entryIdentifier)
Checks if a cache entry with the specified identifier exists.
bool
remove(string $entryIdentifier)
Removes all cache entries matching the specified identifier.
Usually this only affects one entry but if - for what reason ever - old entries for the identifier still exist, they are removed as well.
void
flush()
Removes all cache entries of this cache.
int
flushByTag(string $tag)
Removes all cache entries of this cache which are tagged by the specified tag.
array
findIdentifiersByTag(string $tag)
Finds and returns all cache entry identifiers which are tagged by the specified tag.
void
collectGarbage()
Does garbage collection
protected string
getNotExpiredStatement()
Returns an SQL statement that evaluates to true if the entry is not expired.
protected void
connect()
Connect to the database
protected void
createCacheTables()
Creates the tables needed for the cache backend.
mixed
current()
Returns the data of the current cache entry pointed to by the cache entry iterator.
void
next()
Move forward to the next cache entry.
string
key()
Returns the identifier of the current cache entry pointed to by the cache entry iterator.
bool
valid()
Checks if the current position of the cache entry iterator is valid.
void
rewind()
Rewinds the cache entry iterator to the first element and fetches cacheEntries.
protected string
context()
No description
Result
setup()
Connects to the configured PDO database and adds/updates table schema if required
Result
getStatus()
Validates that configured database is accessible and schema up to date