npm.io
0.1.0 • Published 1 week ago

@xfcfam/xf-kv-redis

Licence
MIT
Version
0.1.0
Deps
1
Size
27 kB
Vulns
0
Weekly
0

@xfcfam/xf-kv-redis

Redis adapter for @xfcfam/xf-kv — the KeyValueRepository contract over ioredis.

ioredis is bundled and wired internally — you never import it. Name your concrete class by domain (SessionRepository), not by technology.

Install

npm i @xfcfam/xf @xfcfam/xf-kv @xfcfam/xf-kv-redis

Quick start

import { RedisKeyValueRepository } from '@xfcfam/xf-kv-redis'

export class SessionRepository extends RedisKeyValueRepository<Session> {
  constructor() { super({ url: process.env.REDIS_URL, namespace: 'sess', defaultTtl: 3600 }) }
}

Exported Components

Generalizations
Component Description
RedisKeyValueRepository<V> Backs the contract with native Redis commands — GET · SET … EX · DEL · EXISTS · INCRBY · MGET · pipelined SET · TTL · SCAN+DEL.
Utilities
Component Description
RedisErrorUtils Maps transport codes (ECONNREFUSED, …) to ConnectionException.

Full TTL introspection and namespace-scoped clear() are supported (unlike the Memcached adapter). Pass url, or a full ioredis options object via redis.

Documentation

Full specification → xfcfam.org

License

MIT

Keywords