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

[QUESTION] Is it possible to have distinct objects for L1 and L2? #321

Open
mejas opened this issue Oct 23, 2024 · 1 comment
Open

[QUESTION] Is it possible to have distinct objects for L1 and L2? #321

mejas opened this issue Oct 23, 2024 · 1 comment

Comments

@mejas
Copy link

mejas commented Oct 23, 2024

Hi, right now I am considering using FusionCache as an integration for an existing project, but have a bit of a challenge since it seems that the L1 and L2 caches have to be exactly the same.

A quick overview:

  1. I am currently using IMemoryCache to store compiled Roslyn objects from a string
  2. I would like to add FusionCache, but would like to do the following:
    1. L1 - store the compilation results (delegates) for execution by callers
    2. L2 - store the string data since serializing the delegates is not a guaranteed process

It looks like FusionCache only serializes what it has in L1 for L2 and no way to provide a distinction. Implementing my own IFusionCacheSerializer might work, but if I return the delegate only for L1, the serializer has no access to the string. I could try storing the string as a pair then see it in L2, but now I have a string and wasted memory since its only needed for the serializer.

Why do this?

  1. The compilation process is a bit painful so I would like the results stored in-memory
  2. FusionCache provides a nice backplane integration that I would like to utilize as well (for scaling-up... or having another service signal a change in data)
  3. I would prefer to not roll my own especially with a battle-tested library available

Your thoughts would be greatly appreciated!

@jodydonetti
Copy link
Collaborator

Uuh, this is an interesting challenge!
You made the scenario quite clear, so let me think about it, will let you know.

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

2 participants