Sha256: 758a2755568308cf94c3a885bbe59d05aaadeb0a0e92aeeb56f3f7e76150e2a4

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 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: Rails.cache, cache_prefix: prefix)
      end
    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

2 entries across 2 versions & 1 rubygems

Version Path
infopark_cloud_connector-6.9.1.3.22208381 lib/rails_connector/cms_cache_storage.rb
infopark_cloud_connector-6.9.0.3.197272233 lib/rails_connector/cms_cache_storage.rb