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?
The data in a cache is generally stored in fast access hardware such as RAM (Random-access memory) and may also be used in correlation with a software component. A cache's primary purpose is to increase data retrieval performance by reducing the need to access the underlying slower storage layer.
Slick is a Functional Relational Mapping library for Scala that allows us to query and access a database like other Scala collections. We can write database queries in Scala instead of SQL, thus providing typesafe queries.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With