@go-go-scope/persistence-redis
v2.4.0
Published
Redis persistence adapter for go-go-scope - distributed locks and circuit breaker state
Maintainers
Readme
@go-go-scope/persistence-redis
Redis persistence adapter for go-go-scope - provides distributed locks and circuit breaker state persistence.
Installation
npm install @go-go-scope/persistence-redis ioredisUsage
import { Redis } from 'ioredis'
import { RedisAdapter } from '@go-go-scope/persistence-redis'
import { scope } from 'go-go-scope'
const redis = new Redis(process.env.REDIS_URL)
const persistence = new RedisAdapter(redis, { keyPrefix: 'myapp:' })
await using s = scope({ persistence })
// Acquire a lock with 30 second TTL
const lock = await s.acquireLock('resource:123', 30000)
if (!lock) {
throw new Error('Could not acquire lock')
}
// Use the lock
await lock.release()License
MIT
