Sha256: c1a8268659d3103a55ef634de6fd25e24f7fac5817ba9bbded663d698dc24e36

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 KB

Contents

module RailsConnector

# This module manages storage of different kind of cache data.
module CmsCacheStorage
  VERSION = 'v1'.freeze

  class << self
    attr_writer :cache

    def cache
      @cache ||= begin
        prefix = VERSION.dup
        prefix.concat('-utf8') if String.new.encoding_aware?
        Cache.new(fallback_backend: backend_cache, cache_prefix: prefix)
      end
    end

    def backend_cache=(new_cache)
      @backend_cache = new_cache
      @cache = nil
    end

    def backend_cache
      @backend_cache || ActiveSupport::Cache::FileStore.new(Rails.root + 'tmp/infopark_cache')
    end

    def read_workspace_data(workspace_id)
      cache.read("workspace/#{workspace_id}")
    end

    def write_workspace_data(workspace_id, workspace_data)
      cache.write("workspace/#{workspace_id}", workspace_data)
    end

    def read_content_state(content_state_id)
      cache.read("content/#{content_state_id}")
    end

    def write_content_state(content_state_id, content_state)
      cache.write("content/#{content_state_id}", content_state)
    end

    def read_obj_data(content_state_id, index, key)
      cache.read("content/#{content_state_id}/obj/#{index}/#{key}")
    end

    def write_obj_data(content_state_id, index, key, data)
      cache.write("content/#{content_state_id}/obj/#{index}/#{key}", data)
    end
  end
end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
infopark_cloud_connector-7.1.0 lib/rails_connector/cms_cache_storage.rb
infopark_cloud_connector-7.0.2 lib/rails_connector/cms_cache_storage.rb
infopark_cloud_connector-7.0.1 lib/rails_connector/cms_cache_storage.rb
infopark_cloud_connector-7.0.0 lib/rails_connector/cms_cache_storage.rb
infopark_cloud_connector-6.9.5 lib/rails_connector/cms_cache_storage.rb