chanzuckerberg / redis-memo

A Redis-based version addressable caching system. Memoize pure functions, aggregated database queries, and 3rd party API calls.
https://rubygems.org/gems/redis-memo
MIT License
33 stars 3 forks source link

"Caching active record queries is currently disabled on RedisMemo" #97

Closed Overload119 closed 2 years ago

Overload119 commented 2 years ago

I just installed this gem.

# typed: true
RedisMemo.configure do |config|
  config.expires_in = 3.hours
  config.global_cache_key_version = SecureRandom.uuid
  config.redis = Rails.application.credentials.redis
end

What causes this?

Seems to be this line:

unless connection.respond_to?(:dependency_of)
  raise RedisMemo::WithoutMemoization.new('Caching active record queries is currently disabled on RedisMemo')
end

Where is dependency_of defined?

katyho commented 2 years ago

Are you trying to cache ActiveRecord queries? If so, you need to do so explicitly by specifying which columns you want to memoize, see https://github.com/chanzuckerberg/redis-memo#cache-simple-activerecord-queries .

For reference, this is where dependency_of is defined.