Sha256: 8cacaeb227452fe5b30092047f61f502170a04fe2f8c2b3289dddbef76dd4c5b

Contents?: true

Size: 1014 Bytes

Versions: 22

Compression:

Stored size: 1014 Bytes

Contents

class Card
  class Cache
    # cache-related class methods
    module CardClass
      def retrieve_from_cache cache_key, local_only=false
        return unless cache

        local_only ? cache.soft.read(cache_key) : cache.read(cache_key)
      end

      def retrieve_from_cache_by_id id, local_only=false
        key = Card::Lexicon.name(id)&.key
        return unless key.present?

        retrieve_from_cache key, local_only if key
      end

      def retrieve_from_cache_by_key key, local_only=false
        retrieve_from_cache key, local_only
      end

      def write_to_cache card, local_only=false
        if local_only
          write_to_soft_cache card
        elsif cache
          cache.write card.key, card
        end
      end

      def write_to_soft_cache card
        return unless cache

        cache.soft.write card.key, card
      end

      def expire name
        key = name.to_name.key
        return unless (card = Card.cache.read key)

        card.expire
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
card-1.107.0 lib/card/cache/card_class.rb
card-1.106.0 lib/card/cache/card_class.rb
card-1.105.6 lib/card/cache/card_class.rb
card-1.105.5 lib/card/cache/card_class.rb
card-1.105.4 lib/card/cache/card_class.rb
card-1.105.3 lib/card/cache/card_class.rb
card-1.105.2.pre1 lib/card/cache/card_class.rb
card-1.105.2 lib/card/cache/card_class.rb
card-1.105.1 lib/card/cache/card_class.rb
card-1.105.0 lib/card/cache/card_class.rb
card-1.104.2 lib/card/cache/card_class.rb
card-1.104.1 lib/card/cache/card_class.rb
card-1.104.0 lib/card/cache/card_class.rb
card-1.103.4 lib/card/cache/card_class.rb
card-1.103.3 lib/card/cache/card_class.rb
card-1.103.2 lib/card/cache/card_class.rb
card-1.103.1 lib/card/cache/card_class.rb
card-1.103.0 lib/card/cache/card_class.rb
card-1.101.7 lib/card/cache/card_class.rb
card-1.102.0 lib/card/cache/card_class.rb