In memory cache

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

In memory cache

pz_wang
Hi,

Basically, I need some script to cache data other than session in Ratpack, there are two options:
1. Use guava cache or Redis directly, the same way as you did in DefaultMapSessionStore.java.
2. Come up with a GenericCacheStore which could also be used for caching session.

Any suggestions from your point of view?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: In memory cache

Luke Daley
Administrator
Since Guava is already a Ratpack dependency, I'd be tempted to use its Cache interface as the basis for what you're doing. It's a decent Cache interface and could be used with a Redis implementation.

I'd create a marker subinterface of this, because Ratpack depenedency injection (through Guice) is based on types. This will make it easier to dependency inject and to context lookup. This is what is happening with SessionStorage.

You'd create a Guice module that binds some implementation to this interface. This could be Guava cache backed, or Redis.
Reply | Threaded
Open this post in threaded view
|

Re: In memory cache

Paul_Fairless
In reply to this post by pz_wang
I was just about to start writing the same thing. Basically need to cache the results from external api calls.

If you've made any progress it would be great if you could share?

Thanks
Paul
Reply | Threaded
Open this post in threaded view
|

Re: In memory cache

Luke Daley
Administrator
I'd recommend just starting with Guava's CacheBuilder.