Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for async cache #12

Closed
wants to merge 5 commits into from
Closed

Add support for async cache #12

wants to merge 5 commits into from

Conversation

fregante
Copy link
Collaborator

@fregante fregante commented Nov 16, 2019

Enables and closes #3

Docs

  • Update all mentions of mem to p-memoize in docs
  • Explain difference with mem also on mem's repo

@fregante
Copy link
Collaborator Author

I might need help with the first couple of points in my OP.
@SamVerschueren do you think map-age-cleaner could work with an async Map like https://github.com/lukechilds/keyv?

@fregante fregante changed the title Override with mem Add support for async cache Nov 16, 2019
@SamVerschueren
Copy link
Contributor

Not out of the box I think because it doesn't await for the methods to complete. Basically it only needs an instance with set, has and delete but all of them are called synchronously.

@SamVerschueren
Copy link
Contributor

We can however update map-age-cleaner so we can do mapAgeCleaner.async(map)

@fregante
Copy link
Collaborator Author

Likewise this change perhaps could just be an option on mem:

sindresorhus/memoize#49 (comment)

@fregante
Copy link
Collaborator Author

fregante commented Nov 29, 2019

I was trying to use this in Refined GitHub and soon realized that our forced {data, expiration} format isn't a great fit for external storage.

I was expecting to find items saved as key: value but found them as key: {data: value}. This is (almost) alright when you just use mem with its default cache Map, but in this case:

  • data is stored in this mem-chosen format and needs to be parsed if retrieved without mem
  • the storage may support strings and numbers but mem always wraps them into objects

cc @sindresorhus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Back with Keyv
2 participants