class GraphQL::PersistedQueries::StoreAdapters::RedisWithLocalCacheStoreAdapter
Memory adapter for storing persisted queries
Constants
- DEFAULT_MEMORY_ADAPTER_CLASS
Memory adapter for storing persisted queries
- DEFAULT_REDIS_ADAPTER_CLASS
Redis adapter for storing persisted queries
Attributes
memory_adapter[R]
redis_adapter[R]
Public Class Methods
new(redis_client: {}, expiration: nil, namespace: nil, redis_adapter_class: nil, memory_adapter_class: nil)
click to toggle source
# File lib/graphql/persisted_queries/store_adapters/redis_with_local_cache_store_adapter.rb, line 11 def initialize(redis_client: {}, expiration: nil, namespace: nil, redis_adapter_class: nil, memory_adapter_class: nil) redis_adapter_class ||= DEFAULT_REDIS_ADAPTER_CLASS memory_adapter_class ||= DEFAULT_MEMORY_ADAPTER_CLASS @redis_adapter = redis_adapter_class.new( redis_client: redis_client, expiration: expiration, namespace: namespace ) @memory_adapter = memory_adapter_class.new @name = :redis_with_local_cache end
Public Instance Methods
tracers=(tracers)
click to toggle source
We don't need to implement our own traces for this adapter since the underlying adapters will emit the proper events for us. However, since tracers can be defined at any time, we need to pass them through.
# File lib/graphql/persisted_queries/store_adapters/redis_with_local_cache_store_adapter.rb, line 28 def tracers=(tracers) @memory_adapter.tracers = tracers @redis_adapter.tracers = tracers end
Protected Instance Methods
fetch(hash)
click to toggle source
# File lib/graphql/persisted_queries/store_adapters/redis_with_local_cache_store_adapter.rb, line 35 def fetch(hash) result = @memory_adapter.fetch_query(hash) result ||= begin inner_result = @redis_adapter.fetch_query(hash) @memory_adapter.save_query(hash, inner_result) if inner_result inner_result end result end
save(hash, query)
click to toggle source
# File lib/graphql/persisted_queries/store_adapters/redis_with_local_cache_store_adapter.rb, line 45 def save(hash, query) @redis_adapter.save_query(hash, query) @memory_adapter.save_query(hash, query) end