Skip to content

Ability to use TTL on Maps #66

@szmarczak

Description

@szmarczak

The default store is new Map(). It has no(?) TTL support. But we could do something like:

if (store instanceof Map) {
	store.timers = {};
	store._set = store.set;
	store.set = (key, value, ttl) => {
		clearTimeout(store.timers[key]);
		store.set(key, value);
		store.timers[key] = setTimeout(() => {
			delete store.timers[key];
			store.delete(key);
		}, ttl);
	};
}

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