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 a mechanism (or document how) to pre-warm the cache #100

Open
CAFxX opened this issue Jun 6, 2018 · 3 comments
Open

Add a mechanism (or document how) to pre-warm the cache #100

CAFxX opened this issue Jun 6, 2018 · 3 comments

Comments

@CAFxX
Copy link

CAFxX commented Jun 6, 2018

There seem to be no way to pre-warm the contents of groupcache at startup. My use-case is described in https://groups.google.com/forum/#!topic/golang-nuts/MweGX6QWNyY but, briefly, is to make sure that after startup my application can process at full speed (this requires groupcache to be fully warmed up) instead of taking 20+ minutes for the empty cache to warm up, during which processing is very slow.

@CAFxX CAFxX changed the title Add (or document) how to pre-warm the cache Add a mechanism (or document how) to pre-warm the cache Jun 6, 2018
@fiorix
Copy link

fiorix commented Nov 26, 2018

Isn't it just Get all keys you want pre-loaded?

@CAFxX
Copy link
Author

CAFxX commented Nov 27, 2018

@fiorix that would work in a world (or for the rare scenarios) with no per-operation latencies. My use-case is described in the URL above: if you read that post and think about it, loading all individual keys is what we already do. And it's taking 20+ minutes. With a bulk load operation, we could do the same thing in <30s.

@smyrman
Copy link

smyrman commented Jul 9, 2019

You could chain the cache...

I.e.:

  • A "bulk fetch" Group (cached, Get calls issued at start-up); store items in a data-structure so that individual items can be accessed.
  • A "single item fetch" Group (cached, Get not issued at start-up).
  • An outer Getter wrapping the two others (with no cache) that:
    1. Get the bulk from the first Group, and extracts the relevant sub-item if present.
    2. Fallback to retrieve the item from the single-item Group.

If relevant, the outer Getter could also provide key versioning or expiry emulation by appending content to a section of the key that the underlying Getters ignores, but that's off topic.

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

3 participants