Have ideas to improve npm?Join in the discussion! »

@expo/entity-cache-adapter-redis
TypeScript icon, indicating that this package has built-in type declarations

0.12.0 • Public • Published

@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,
    {
      ...
    },
    {
      ['redis']: {
        cacheAdapterProvider: new RedisCacheAdapterProvider(redisCacheAdapterContext),
      },
    }
  );
};

Keywords

Install

npm i @expo/[email protected]

Version

0.12.0

License

MIT

Unpacked Size

86.5 kB

Total Files

45

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar