lib/restruct/connection.rb in restruct-0.2.0 vs lib/restruct/connection.rb in restruct-1.0.0
- old
+ new
@@ -1,11 +1,25 @@
module Restruct
+
class Connection
- def initialize(*args)
- @args = args
- @redis = Redic.new *args
+ class << self
+
+ def simple(*args)
+ new Redic.new(*args)
+ end
+
+ def with_sentinels(*args)
+ new Redic::Sentinels.new(*args)
+ end
+
+ private :new
+
+ end
+
+ def initialize(redis=nil)
+ @redis = redis || Redic.new
@scripts = {}
@nesting = ::Hash.new { |h,k| h[k] = 0 }
end
def call(*args)
@@ -41,17 +55,9 @@
end
commit unless nested?
rescue => ex
redis.clear unless nested?
raise ex
- end
-
- def read
- redis.client.read
- end
-
- def clone
- Connection.new *@args
end
private
attr_reader :redis, :scripts
\ No newline at end of file