loyalflow
loyalflow

Reputation: 14879

How to create a caching layer on top of slick that could be applied globally?

I am curios if using scala and slick, you could create a flexible caching layer (say using memcached) on top of slick.

Ruby has a cool library called IdentityCache: https://github.com/Shopify/identity_cache

It allows you to simply extend your model class (a trait in scala?) where you tell it to use this cache layer.

You can then tell it to only cache by Id, or cache associations also etc.

Sounds like a very cool thing, how could something like this fit into slick's design?

Upvotes: 5

Views: 1170

Answers (1)

cvogt
cvogt

Reputation: 11270

I was thinking about how to add this to Slick lately, but we don't have any resources assigned to it for the foreseeable future.

You could build a query cache on top of Slick. Invalidating the cache based on the observed write operations on the base data can be very hard for arbitrary queries. You would need to restrict the supported operations for conditions in cached queries, e.g. to only use equality. Oracle and others have similar restrictions in place for their materialized view maintenance features.

Upvotes: 3

Related Questions