sindresorhus / p-memoize

Memoize promise-returning & async functions
MIT License
396 stars 30 forks source link

Add support for async cache #12

Closed fregante closed 4 years ago

fregante commented 4 years ago

Enables and closes #3

Docs

fregante commented 4 years ago

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?

SamVerschueren commented 4 years ago

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 commented 4 years ago

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

fregante commented 4 years ago

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

https://github.com/sindresorhus/mem/issues/49#issuecomment-557087637

fregante commented 4 years ago

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:

cc @sindresorhus