@kitiumai/auth-redis
v1.0.1
Published
Redis cache adapter for Kitium Auth
Maintainers
Readme
@kitium/auth-redis (Redis Cache Adapter)
Redis cache adapter for Kitium Auth core.
- Caches API key verification results and principal resolution
- Simple JSON serialization for values; pluggable TTLs per call
Install
npm install @kitium/auth-redis redisUsage
import { AuthCore } from '@kitium/auth'
import { RedisCacheAdapter } from '@kitium/auth-redis'
import { PostgresStorageAdapter } from '@kitium/auth-postgres'
const storage = new PostgresStorageAdapter(process.env.DATABASE_URL!)
const cache = new RedisCacheAdapter(process.env.REDIS_URL!)
const auth = new AuthCore(storage, {
jwtSecret: process.env.JWT_SECRET!,
cache
})
await auth.initialize()Common Operations
await cache.connect()
await cache.set('key', { foo: 'bar' }, 300)
const value = await cache.get('key')
const exists = await cache.exists('key')
await cache.expire('key', 60)
await cache.del('key')
await cache.disconnect()With AuthCore
AuthCore uses cache keys like apikey:<id> and principal:<id> to speed up verification and resolution.
License
MIT
