Sha256: 7cccf91bbda63b1eb9b9eeb0f664aa7d5fcdf9ee2f212673e075c21cb3ed5ead

Contents?: true

Size: 943 Bytes

Versions: 1

Compression:

Stored size: 943 Bytes

Contents

require 'app_cache/version'
require 'app_cache/engine'
require 'app_cache/local_file_cache'
require "app_cache/railtie" if defined?(Rails)

module AppCache
  CACHE_TYPE_REDIS = 'redis'
  CACHE_TYPE_FILE = 'file'

  class << self
    attr_accessor :storage

    def new(cache_type, options = {})
      case cache_type
        when CACHE_TYPE_REDIS
          @storage = Redis.new(:url => options[:url])
        else
          @storage = AppCache::LocalFileCache.new(options[:file_path])
      end
      #更新缓存
      AppCache::SystemParam.cache_update
    end

    def sys_params_cache
      h_params = AppCache::SystemParam.get_params_cache
      h_params
    end

    def sys_params_db
      h = {}
      AppCache::SystemParam.all.each do |sp|
        h.store(sp.param_code, sp.param_value)
      end
      return h
    end

    def get_param_value(key)
      val = AppCache::SystemParam.get_param_value(key)
      val
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
app_cache-0.1.0 lib/app_cache.rb