Sha256: ac5c99c052916b49e7b91b60c63a199432f68617580f0b9e9fa46840c6f929e7

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 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_content_state_id(workspace_id)
      cache.read("workspace/#{workspace_id}/content_state")
    end

    def write_workspace_content_state_id(workspace_id, content_state_id)
      cache.write("workspace/#{workspace_id}/content_state", content_state_id)
    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

6 entries across 6 versions & 1 rubygems

Version Path
infopark_cloud_connector-6.8.3.174.51542603 lib/rails_connector/cms_cache_storage.rb
infopark_cloud_connector-6.8.3.115.227021242 lib/rails_connector/cms_cache_storage.rb
infopark_cloud_connector-6.8.3.73.75172665 lib/rails_connector/cms_cache_storage.rb
infopark_cloud_connector-6.8.3.2.153416031 lib/rails_connector/cms_cache_storage.rb
infopark_cloud_connector-6.8.3.67.110847540 lib/rails_connector/cms_cache_storage.rb
infopark_cloud_connector-6.8.3.1.23895778 lib/rails_connector/cms_cache_storage.rb