module AsyncCache::Workers::Base
Public Class Methods
clear()
click to toggle source
Clear the active jobs from this worker's queue.
# File lib/async_cache/workers/base.rb, line 29 def self.clear raise NotImplementedError end
enqueue_async_job(key:, version:, expires_in:, block:, arguments:)
click to toggle source
Public interface for enqueuing jobs. This is what is called by {AsyncCache::Store}.
# File lib/async_cache/workers/base.rb, line 35 def self.enqueue_async_job(key:, version:, expires_in:, block:, arguments:) raise NotImplementedError end
has_workers?()
click to toggle source
@return [Boolean] Returns whether or not workers are running to
process enqueue AsyncCache jobs. Return `false` if this functionality isn't available by the underlying system.
# File lib/async_cache/workers/base.rb, line 24 def self.has_workers? raise NotImplementedError end
Public Instance Methods
perform(key, version, expires_in, block_arguments, block_source)
click to toggle source
@param [String] key String or array cache key computed by `AsyncCache` @param [Fixnum] version Monotonically increasing integer indicating
the version of the resource being cached
@param [Fixnum] expires_in Optional expiration to pass to the cache store @param [Array] block_arguments Arguments with which to call the block @param [String] block_source Ruby source to evaluate to produce the value
# File lib/async_cache/workers/base.rb, line 45 def perform key, version, expires_in, block_arguments, block_source _cached_data, cached_version = backend.read key return unless version > (cached_version || 0) value = [eval(block_source).call(*block_arguments), version] backend.write key, value, :expires_in => expires_in end
Private Instance Methods
backend()
click to toggle source
# File lib/async_cache/workers/base.rb, line 56 def backend AsyncCache.backend end