Skip to content

How to clear cache of a method that has a custom hashFunction for a specific hash? #56

@mbartn

Description

@mbartn

Example:

class MemoizedClass {
    @Memoize({
        tags: ["tag1"], hashFunction: function (arg1, arg2) {
            return arg1 + arg2
        }
    })
    public async expensiveFunction(arg1: string, arg2: string) {
        return arg1 + arg2
    }
}

async function main() {
    const instance = new MemoizedClass()

    const result = instance.expensiveFunction("1", "1")
    const result2 = instance.expensiveFunction("2", "2")

    clear(["tag1"]) // How to clear it only for arguments ("1", "1")?
}

main().catch(console.error);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions