LazyPhpRedisCorpusClient
Rasuvaeff\PropertyTesting\Runner\Redis\LazyPhpRedisCorpusClient
Class — Package: property-testing-core — Source — Version: v1.0.0-1-g88fdee2
Implements: Runner\Redis\CorpusClient
A PhpRedisCorpusClient that connects on first use.
Runner\Redis\PhpRedisCorpusClient takes an already-connected \Redis — the right contract for a class that does not own the connection — but resolving a DSN must not open a socket. A suite that names a corpus it never touches (every property pinned by an explicit seed, say) would otherwise fail at startup against a server it never needed, and CI proved it: the eager version was red everywhere the extension was installed and Redis was not running.
predis is lazy by construction, so only this side needed the wrapper.
Constructor
__construct(
\Runner\Redis\RedisDsn $dsn,
)| Parameter | Type | Default | Description |
|---|---|---|---|
$dsn | Runner\Redis\RedisDsn | required | Where to connect on first use. |
Methods
get()
get(string $key): ?stringThe stored document for $key, or null when the key does not exist.
Documentation inherited from Runner\Redis\CorpusClient.
$key— The corpus key, already namespaced by the caller.
Throws:
RuntimeException— When the first use cannot connect or select the database.
compareAndSet()
compareAndSet(
string $key,
?string $expected,
?string $document,
): boolStores $document for $key only if the stored value is still $expected — the whole read-modify-write of a corpus write, made safe without holding a lock across a round trip.
Documentation inherited from Runner\Redis\CorpusClient.
$key— The corpus key, already namespaced by the caller.$expected— The document the caller read, or null when the key was absent.$document— The document to store, or null to delete the key (an empty corpus is an absent key, exactly as an empty corpus is an absent file on disk).
Throws:
RuntimeException— When the first use cannot connect or select the database.