9.2.0 • Published 3 years ago

@serverless-seoul/cache v9.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

@serverless-seoul/cache

Build Status

Installation

$ npm install @serverless-seoul/cache --save

Features

  1. Support Promise for every method
  2. Support for get / set methods
  3. Advanced cache-access pattern such as fetch.

Example

describe("#fetchMulti", () => {
  const memcached = new Memcached();
  const fetcher = new MemcachedFetcher(memcached);

  it("should fetch only missing sets", async () => {
    const res1 = await fetcher.multiFetch(
      [1, 2, 3, 4, 5],
      (arg) => `v1-${arg}`,
      3600,
      async (args) => {
        return args.map((arg) => arg * arg);
      }
    );
    expect(res1).to.deep.eq([1, 4, 9, 16, 25]);

    // it's using same hash key, so should reuse cache for exsiting values
    const res2 = await fetcher.multiFetch(
      [1, 2, 100, 200, 5],
      (arg) => `v1-${arg}`,
      3600,
      async (args) => {
        return args.map((arg) => arg + arg);
      }
    );
    expect(res2).to.deep.eq([1, 4, 200, 400, 25]);

    const res3 = await fetcher.multiFetch(
      [],
      (arg) => `v1-${arg}`,
      3600,
      async (args) => {
        return args.map((arg) => arg);
      }
    );
    expect(res3).to.deep.eq([]);
  });
});

Supported Drivers

  • Redis
  • Clustered Redis
8.1.0

3 years ago

8.0.5

3 years ago

9.0.0-beta.0

3 years ago

8.0.6

3 years ago

9.2.0

3 years ago

9.1.0

3 years ago

9.0.0

3 years ago

8.0.4

3 years ago

8.0.3

3 years ago

8.0.2

3 years ago

8.0.1

3 years ago