Sha256: 6463262f772166f637d5cc99cb030bf5b73820640f0b0a908f1aa58eed7b1838

Contents?: true

Size: 746 Bytes

Versions: 6

Compression:

Stored size: 746 Bytes

Contents

module Asynchronic
  module DataStore
    class Redis

      include Helper

      def initialize(*args)
        @connection = ::Redis.new *args
      end

      def [](key)
        value = @connection.get key.to_s
        value ? Marshal.load(value) : nil
      rescue => ex
        Asynchronic.logger.warn('Asynchronic') { ex.message }
        value
      end

      def []=(key, value)
        @connection.set key.to_s, Marshal.dump(value)
      end

      def delete(key)
        @connection.del key.to_s
      end

      def keys
        @connection.keys.map { |k| Key.new k }
      end

      def connection
        @connection.client.options
      end

      def self.connect(options)
        new options
      end
      
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
asynchronic-0.3.1 lib/asynchronic/data_store/redis.rb
asynchronic-0.3.0 lib/asynchronic/data_store/redis.rb
asynchronic-0.2.3 lib/asynchronic/data_store/redis.rb
asynchronic-0.2.2 lib/asynchronic/data_store/redis.rb
asynchronic-0.2.1 lib/asynchronic/data_store/redis.rb
asynchronic-0.2.0 lib/asynchronic/data_store/redis.rb