Sqlcachedependency not invalidating cache

Rated 3.88/5 based on 572 customer reviews

At my previous job, we had a bunch of systems talking to a single database. We wanted to add memcached to the rails apps via cache-money[1].That'll handle read-through/write-through caching for vanilla rails stuff, but we had to somehow invalidate the cache for updates that happen outside of Active Record:: Base#save (e.g. In the end, we settled upon the same approach[2] as in the article.cache user lookups by username), since the invalidator would just know what to do.[1] https://github.com/nkallen/cache-money[2] This was actually on 8.4, so unfortunately there was no NOTIFY.Instead, a plpython trigger would send a message to invalidator (persistent tcp conn per pg process), but this had the unfortunate consequences of 1. firing even in the event of a rollback This was actually on 8.4, so unfortunately there was no NOTIFY.Creating a new cache dependency doesn’t help us much if we can’t get a reference to it later - otherwise, how can we call One quick singleton pattern later and we can call these methods from throughout our codebase.When we invoke our slow action for the first time we need to add the dependency to the response using a unique key to identify the slow resource: to your controllers instead of accessing it directly, but the singleton will suffice for this example.

You just need to use an asynchronous driver and you can happily LISTEN and do queries at the same time (of course you won't get notifies while a query is processing - the Postgres protocol has no concept of multiplexing).Of course, YMMV and the increased cost might deter you from going this way.Why can't you use a connection that has issued LISTEN for anything else?But the challenging is to maintain consistency of cache items when there's eviction.Let's say if Redis cache decides to evict "category:[Category Id]:questions:notpublished" cache item, how do i make sure all other cache items related to that category id also invalidated?

Leave a Reply