Sha256: 36b894f5be1fbc14ac25c1318c6b6922e01c0399955d0fe41f0207f271480923

Contents?: true

Size: 1.26 KB

Versions: 6

Compression:

Stored size: 1.26 KB

Contents

#require 'redis/connection'
require 'redis'

module Auger

  class Project
    def redis(port = 6379, &block)
      @connections << Auger::Redis.load(port, &block)
    end
  end

  class Redis < Auger::Connection
    def open(host, options)
      ::Redis.new options.merge({:host => host, :thread_safe => true, :port => options[:port]})
    end

    def close(redis)
      redis.quit
    end

    def ping(&block)
      @requests << Auger::RedisPing.load(nil, &block)
    end

    def info(&block)
      @requests << Auger::RedisInfo.load(nil, &block)
    end

    def dbsize(&block)
      @requests << Auger::RedisDbsize.load(nil, &block)
    end

    def get(key, &block)
      @requests << Auger::RedisGet.load(key, &block)
    end

    def exists(key, &block)
      @requests << Auger::RedisExists.load(key, &block)
    end

  end

  class RedisPing < Auger::Request
    def run(redis)
      redis.ping
    end
  end

  class RedisInfo < Auger::Request
    def run(redis)
      redis.info
    end
  end

  class RedisDbsize < Auger::Request
    def run(redis)
      redis.dbsize
    end
  end

  class RedisGet < Auger::Request
    def run(redis)
      redis.get(@arg)
    end
  end

  class RedisExists < Auger::Request
    def run(redis)
      redis.exists(@arg)
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
auger-1.3.6 lib/auger/plugin/redis.rb
auger-1.3.5 lib/auger/plugin/redis.rb
auger-1.3.4 lib/auger/plugin/redis.rb
auger-1.3.3 lib/plugins/redis.rb
auger-1.3.2 lib/plugins/redis.rb
auger-1.3.1 lib/plugins/redis.rb