Sha256: 8bab98214f01c27c9ae10a0a1666e7c3db42139d6e92dff21ff7dad9c86d181d

Contents?: true

Size: 519 Bytes

Versions: 2

Compression:

Stored size: 519 Bytes

Contents

class Card
  class Cache
    # class methods for Card::Cache::Shared
    module SharedClass
      def stamp
        @stamp ||= Cardio.cache.fetch(stamp_key) { new_stamp }
      end

      # stamp generator
      def new_stamp
        Time.now.to_i.to_s(36) + rand(999).to_s(36)
      end

      def stamp_key
        "#{Cardio.database}-stamp"
      end

      def renew
        @stamp = nil
      end

      def reset
        @stamp = new_stamp
        Cardio.cache.write stamp_key, @stamp
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
card-1.108.1 lib/card/cache/shared_class.rb
card-1.108.0 lib/card/cache/shared_class.rb