Sha256: dea650e2d0290e5d9cdb4aea90edabebd0781692fdf50273cfaaa63487b21484

Contents?: true

Size: 513 Bytes

Versions: 1

Compression:

Stored size: 513 Bytes

Contents

module ActiveModelCachers
  class CacheService
    def initialize(id)
      @id = id
    end

    def get
      @cached_data ||= get_from_cache
    end

    def clean_cache
      @cached_data = nil
      Rails.cache.delete(cache_key)
    end

    private

    def cache_key
      fail 'not implement'
    end

    def get_without_cache
      fail 'not implement'
    end

    def get_from_cache
      ActiveModelCachers.config.store.fetch(cache_key, expires_in: 30.minutes){ get_without_cache }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_model_cachers-1.0.0 lib/active_model_cachers/cache_service.rb