Class: AnyCache::Adapters::ActiveSupportNaiveStore::Expire Private

Inherits:
Operation
  • Object
show all
Defined in:
lib/any_cache/adapters/active_support_naive_store/expire.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

Constant Summary

Constants inherited from Operation

Operation::DEAD_TTL, Operation::NO_EXPIRATION_TTL, Operation::READ_MULTI_EMPTY_KEYS_SET

Instance Method Summary collapse

Methods inherited from Operation

#initialize

Constructor Details

This class inherits a constructor from AnyCache::Adapters::ActiveSupportNaiveStore::Operation

Instance Method Details

#call(key, expires_in: DEAD_TTL) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Parameters:

  • key (String)
  • expires_in (Hash) (defaults to: DEAD_TTL)

    a customizable set of options

Options Hash (expires_in:):

  • (Integer, NilClass)

Since:

  • 0.1.0



13
14
15
16
17
18
19
# File 'lib/any_cache/adapters/active_support_naive_store/expire.rb', line 13

def call(key, expires_in: DEAD_TTL)
  fetch_entry(key).tap do |entry|
    next unless entry
    is_alive = expires_in.positive?
    is_alive ? write(key, entry.value, expires_in: expires_in) : delete(key)
  end
end

#fetch_entry(key) ⇒ NilClass, ActiveSupport::Cache::Entry

Parameters:

  • key (String)

Returns:

  • (NilClass, ActiveSupport::Cache::Entry)


# File 'lib/any_cache/adapters/active_support_naive_store/expire.rb', line 21