Sha256: e1d3f090f2c1d0c8be77e0fb1e522b7f4120f3560ee3e32ab7387654ae2f514a

Contents?: true

Size: 1.67 KB

Versions: 7

Compression:

Stored size: 1.67 KB

Contents

require 'redis'
require 'redis/store/factory'
require 'redis/distributed_store'
require 'redis/store/namespace'
require 'redis/store/serialization'
require 'redis/store/version'
require 'redis/store/redis_version'
require 'redis/store/ttl'
require 'redis/store/interface'
require 'redis/store/redis_version'

class Redis
  class Store < self
    include Ttl, Interface, RedisVersion

    def initialize(options = {})
      super

      unless options[:marshalling].nil?
        puts %(
          DEPRECATED: You are passing the :marshalling option, which has been
          replaced with `serializer: Marshal` to support pluggable serialization
          backends. To disable serialization (much like disabling marshalling),
          pass `serializer: nil` in your configuration.

          The :marshalling option will be removed for redis-store 2.0.
        )
      end

      @serializer = options.key?(:serializer) ? options[:serializer] : Marshal

      unless options[:marshalling].nil?
        @serializer = options[:marshalling] ? Marshal : nil
      end

      _extend_marshalling options
      _extend_namespace   options
    end

    def reconnect
      @client.reconnect
    end

    def to_s
      "Redis Client connected to #{location} against DB #{@client.db}"
    end

    def location
      if @client.path
        @client.path
      else
        h = @client.host
        h = "[#{h}]" if h.include?(":")
        "#{h}:#{@client.port}"
      end
    end

    private
      def _extend_marshalling(options)
        extend Serialization unless @serializer.nil?
      end

      def _extend_namespace(options)
        @namespace = options[:namespace]
        extend Namespace
      end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
redis-store-1.9.2 lib/redis/store.rb
redis-store-1.9.1 lib/redis/store.rb
redis-store-1.9.0 lib/redis/store.rb
redis-store-1.8.2 lib/redis/store.rb
redis-store-1.8.1 lib/redis/store.rb
redis-store-1.8.0 lib/redis/store.rb
redis-store-1.6.0 lib/redis/store.rb