Skip to content

v1.1.0

Compare
Choose a tag to compare
@leebyron leebyron released this 12 Jan 03:34
· 194 commits to main since this release

New:

  • Provide a custom cache-key function. #15 — Since JavaScript does not use value equality, but fetch keys are often treated as values, this allows for a custom function to be provided to produce a cache-key for any load-key. Example:

    var loader = new DataLoader(keys => promiseToGetKeys(keys), { cacheKeyFn: key => key._id });
    var first = loader.load({ _id: 'abc123' });
    var second = loader.load({ _id: 'abc123' });
    assert(first === second);
  • Provide a custom cache instance. #17 — By default, DataLoader uses a Map as a cache. However this simple cache does not support anything like TTL or a cache eviction policy. Now you may provide any object which implements the Map API to use as a cache. Example:

    var loader = new DataLoader(keys => promiseToGetKeys(keys), { cacheMap: new LRUCacheMap() });