@expo/entity-cache-adapter-redis
Redis cache adapter for @expo/entity
Last updated an hour ago by wschurman .
MIT · Original npm · Tarball · package.json
$ cnpm install @expo/entity-cache-adapter-redis 
SYNC missed versions from official npm registry.

@expo/entity-cache-adapter-redis

ioredis cache adapter for @expo/entity.

Documentation

Usage

During EntityCompanionProvider instantiation:

import Redis from 'ioredis';

const redisCacheAdapterContext = {
  redisClient: new Redis(new URL(process.env.REDIS_URL!).toString()),
  makeKeyFn(...parts: string[]): string {
    const delimiter = ':';
    const escapedParts = parts.map((part) =>
      part.replace('\\', '\\\\').replace(delimiter, `\\${delimiter}`)
    );
    return escapedParts.join(delimiter);
  },
  cacheKeyPrefix: 'ent-',
  cacheKeyVersion: 1,
  ttlSecondsPositive: 86400, // 1 day
  ttlSecondsNegative: 600, // 10 minutes
};

export const createDefaultEntityCompanionProvider = (
  metricsAdapter: IEntityMetricsAdapter = new NoOpEntityMetricsAdapter()
): EntityCompanionProvider => {
  return new EntityCompanionProvider(
    metricsAdapter,
    {
      ...
    },
    {
      [CacheAdapterFlavor.REDIS]: {
        cacheAdapterProvider: new RedisCacheAdapterProvider(redisCacheAdapterContext),
      },
    }
  );
};

Current Tags

  • 0.5.2                                ...           latest (an hour ago)

5 Versions

  • 0.5.2                                ...           an hour ago
  • 0.5.1                                ...           7 hours ago
  • 0.5.0                                ...           10 hours ago
  • 0.4.0                                ...           a month ago
  • 0.3.0                                ...           2 months ago
Downloads
Today 22
This Week 22
This Month 22
Last Day 0
Last Week 0
Last Month 10
Dependencies (1)
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |