Skip to content

max: 0 doesn't disable cache. #145

@monkekode

Description

@monkekode

Hi, I'm trying to memoize a function to the point where there is no cache, but concurrent execution also doesn't happen. To do this max: 0 should work to disable cache, but in practice it doesn't. Example:

import memoizee from 'memoizee';
import {sleep} from "../lib/util.js";

const x = async (s: string) => {
    await sleep(500);
    console.log(`Running ${s}`);
}

const m = memoizee(x, {max: 0, primitive: true});

await m('TEST');
await m('TEST');
await m('TEST 2');
await m('TEST');

In this case output is

Running TEST
Running TEST 2

Meaning the values are memoized. Setting max to 1 works properly, as do higher values.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions