PdoStore
class PdoStore implements StoreInterface
PdoStore is a StoreInterface implementation using a PDO connection.
Lock metadata are stored in a table. You can use createTable() to initialize a correctly defined table.
CAUTION: This store relies on all client and server nodes to have synchronized clocks for lock expiry to occur at the correct time. To ensure locks don't expire prematurely; the TTLs should be set with enough extra time to account for any clock drift between nodes.
Methods
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 lock is actually used.
Creates the table to store lock keys which can be called once for setup.
Details
__construct(PDO|Connection|string $connOrDsn, array $options = array(), float $gcProbability = 0.01, int $initialTtl = 300)
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 lock is actually used.
List of available options: * db_table: The name of the table [default: lock_keys] * db_id_col: The column where to store the lock key [default: key_id] * db_token_col: The column where to store the lock token [default: key_token] * db_expiration_col: The column where to store the expiration [default: key_expiration] * 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()]
waitAndSave(Key $key)
Waits until a key becomes free, then stores the resource.
If the store does not support this feature it should throw a NotSupportedException.
putOffExpiration(Key $key, $ttl)
Extends the ttl of a resource.
If the store does not support this feature it should throw a NotSupportedException.