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

Local cache #1

Closed
dodyg opened this issue Nov 4, 2013 · 4 comments
Closed

Local cache #1

dodyg opened this issue Nov 4, 2013 · 4 comments
Assignees
Milestone

Comments

@dodyg
Copy link

dodyg commented Nov 4, 2013

Do you have option for storing cache locally (in memory) as well as out of process? This way the cache will check for RAM and only go out of process when it does not exist.

@ghost ghost assigned haneytron Nov 5, 2013
@haneytron
Copy link
Owner

Can you tell me a little bit more about your expectations around such a feature? I have seen it in AppFabric for example, and think I get what you mean (basically a RAM drive), but what do you want to get out of it? It's not particularly cheap or easy to keep the local cache in sync with the remote cache (requires a polling mechanism from client to server or two-way communication that remains open so the server can push back to the client). If you're able and willing to accept some delay (seconds, minutes, hours?) in the locally cache data reflecting the remotely cached data (eventual consistency), it could be done quite easily. Let me know your thoughts!

@dodyg
Copy link
Author

dodyg commented Nov 5, 2013

Here's my scenario: I need to keep track of session information (sessionId + some other bits of info) for a REST API in my application. Memory cache is nice for this - I can just store the session info in RAM and retrieve them every time to verify the incoming calls.

The problem is that when IIS recycle, you lose this information. So what we do is create a second storage for these session information in the database. So the logic is

  • Check SessionID in local cache.
  • If not exist, check the DB store.
  • If exists, populate the local cache to be used next time.

Now when I expire the session, I remove the info at the local cache, delete the row in the DB and send message to the other machines to expire their local cache as well.

We can in fact use an external caching to replace the role of DB store.I just need a second RAM storage to survive IIS recycle.

The 2nd scenario is simply API niceties: static lookup data. I really don't want to go out of process to get country list, zip code list, etc.

@haneytron
Copy link
Owner

Keeping track of data locally and keeping it up to date would be very expensive... A magnitude of N pushes of data where N is the number of cache hosts... This would be required because if you round-robin'd your web servers and had 20 of them, all 20 would need the latest, most up-to-date session information for each request... Not only that, but race conditions would exist where fast consecutive requests could beat the Session data update to the local RAM... I will definitely implement a "boost mode" that does some local caching, but it will have to start out as eventual consistency in order to be light on the network I/O... After all, you don't save much by storing session locally on each server if you have to constantly send it to every other server. Thank you for the input - scheduling local caching boost for 1.2!

@haneytron
Copy link
Owner

I have added this feature in 1.2.0 and am closing this issue. Thanks @dodyg !

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

No branches or pull requests

2 participants