feat(cooler): Cache.Pull returns and removes a value atomically
- Cache.Pull(ctx, key) ([]byte, bool, error), Laravel's Cache::pull
- Redis driver runs GETDEL (Redis 6.2+); memory driver uses otter Compute
with InvalidateOp under the per-key lock; expired keys report not found
- TestPullSmoke over the memory driver and miniredis, ExampleCache_Pull
- README and docs/services/caching.md ("One-time values")
This commit is contained in:
@@ -74,6 +74,11 @@ type Attempter interface {
|
||||
type Cache interface {
|
||||
// Get returns the value at key and whether it was found.
|
||||
Get(ctx context.Context, key string) ([]byte, bool, error)
|
||||
// Pull returns the value at key and removes it in one atomic step, as
|
||||
// Laravel's Cache::pull. found is false when the key is missing or
|
||||
// expired; of two concurrent callers at most one gets found=true. The
|
||||
// Redis driver uses GETDEL (Redis 6.2 or newer).
|
||||
Pull(ctx context.Context, key string) ([]byte, bool, error)
|
||||
// Set stores value at key for ttl (0 or less: no expiry).
|
||||
Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
|
||||
// Has reports whether key holds a live value.
|
||||
|
||||
Reference in New Issue
Block a user