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 "has" method #16

Open
eight04 opened this issue Mar 31, 2019 · 1 comment
Open

Add "has" method #16

eight04 opened this issue Mar 31, 2019 · 1 comment

Comments

@eight04
Copy link

eight04 commented Mar 31, 2019

I want to check if a resource has already been cached. Maybe we can have a has method or a getMeta method that only returns the metadata without the binary file? Also, we need a method to refresh a cache i.e. to update the expire tag of the resource.

Other questions:

  1. What will happen when the size limit is reached?
  2. What will happen when the count limit is reached?
  3. Is it possible to use unlimited size and count?
@eight04
Copy link
Author

eight04 commented Apr 1, 2019

After working on #19. I found that what I really need is the ability to save metadata (file size, name, etc) along with the binary. For example:

// getting the metadata
try {
  return await cache.getMeta(key);
} catch (err) {}
const {resource, meta} = await fetchResource(key);
await cache.set(key, resource);
await cache.setMeta(key, meta);
// it will be better to set both the resource and the metadata at once
// e.g. cache.add({key, value: resource, meta})
return meta;

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

No branches or pull requests

1 participant