CorpusClient
Rasuvaeff\PropertyTesting\Runner\Redis\CorpusClient
Interface — Package: property-testing-core — Source — Version: v1.0.0-1-g88fdee2
Implemented by: Runner\Redis\LazyPhpRedisCorpusClient, Runner\Redis\PhpRedisCorpusClient, Runner\Redis\PredisCorpusClient
The two operations Runner\RedisCorpus needs from a Redis client, and nothing else.
The seam exists for three reasons, in order of how much they cost when it is missing: the two PHP clients disagree about how commands are called (phpredis has real methods, predis routes them through __call annotations that no static analyser resolves across releases); the corpus is then unit-testable against an in-memory double instead of only against a live server; and a consumer with a connection pool, a namespaced wrapper or a test harness can supply its own without this package knowing about it.
Methods
get()
get(string $key): ?stringThe stored document for $key, or null when the key does not exist.
$key— The corpus key, already namespaced by the caller.
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.
$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).