Sha256: 37900d560bd133d4a8706f0527e69e99ec9370eed3c83dd2efd6a855713ad55d

Contents?: true

Size: 395 Bytes

Versions: 4

Compression:

Stored size: 395 Bytes

Contents

module Ddr
  module CacheableAuxiliaryResource

    def with_cache(key, &block)
      block.call.tap { |value| cache.write(key, value) }
    rescue ActiveResource::ServerError => e
      if value = cache.fetch(key)
        logger.error(e) if logger
        value
      else
        raise
      end
    end

    def cache
      @cache ||= ActiveSupport::Cache::MemoryStore.new
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ddr-core-1.2.0 app/models/ddr/cacheable_auxiliary_resource.rb~
ddr-core-1.2.0.rc3 app/models/ddr/cacheable_auxiliary_resource.rb~
ddr-core-1.2.0.rc2 app/models/ddr/cacheable_auxiliary_resource.rb~
ddr-core-1.2.0.rc1 app/models/ddr/cacheable_auxiliary_resource.rb~