Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Allow users to specify different connection options for the redis store #76

Merged
merged 1 commit into from

2 participants

@NZKoz

This allows you to use redis running on alternative hosts etc without having to create a subclass and override the private redis method.

@NZKoz NZKoz Allow users to specify different connection options for the redis store
This allows you to use redis running on alternative hosts etc without having to create a subclass and override the private redis method.
63e0b9c
@SamSaffron SamSaffron merged commit 99329b0 into SamSaffron:master
@SamSaffron
Owner

Looks good, did you end up getting MiniProfiler going? do you need a gem release for this asap?

@NZKoz
@NZKoz

said 'random issue was #77

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 25, 2012
  1. @NZKoz

    Allow users to specify different connection options for the redis store

    NZKoz authored
    This allows you to use redis running on alternative hosts etc without having to create a subclass and override the private redis method.
This page is out of date. Refresh to see the latest.
View
6 Ruby/lib/mini_profiler/storage/redis_store.rb
@@ -5,8 +5,8 @@ class RedisStore < AbstractStore
EXPIRE_SECONDS = 60 * 60 * 24
def initialize(args)
- args ||= {}
- @prefix = args[:prefix] || 'MPRedisStore'
+ @args = args || {}
+ @prefix = @args.delete(:prefix) || 'MPRedisStore'
end
def save(page_struct)
@@ -36,7 +36,7 @@ def get_unviewed_ids(user)
def redis
require 'redis' unless defined? Redis
- Redis.new
+ Redis.new @args
end
end
View
22 Ruby/spec/components/redis_store_spec.rb
@@ -6,6 +6,28 @@
describe Rack::MiniProfiler::RedisStore do
+ context 'establishing a connection to something other than the default' do
+ before do
+ @store = Rack::MiniProfiler::RedisStore.new(:db=>2)
+ end
+
+ describe "connection" do
+ it 'can still store the resulting value' do
+ page_struct = Rack::MiniProfiler::PageTimerStruct.new({})
+ page_struct['Id'] = "XYZ"
+ page_struct['Random'] = "random"
+ @store.save(page_struct)
+ end
+
+ it 'uses the correct db' do
+ # redis is private, and possibly should remain so?
+ underlying_client = @store.send(:redis).client
+
+ underlying_client.db.should == 2
+ end
+ end
+ end
+
context 'page struct' do
before do
Something went wrong with that request. Please try again.