Skip to content
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.

Commit

Permalink
Synchronize redis operations with task-aware latch.
Browse files Browse the repository at this point in the history
  • Loading branch information
marshall-lee committed Aug 21, 2015
1 parent bd7451d commit c45f02a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/celluloid/redis.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
require "redis"

require "celluloid/redis/version"
require "celluloid/io"

module Celluloid
class Redis < ::Redis
VERSION = CelluloidRedis::VERSION

def initialize(*args)
super
if @options[:driver] == :celluloid
@latch = Celluloid::IO::Stream::Latch.new
end
end

def synchronize
if @latch
@latch.synchronize { yield @client }
else
super(&proc)
end
end
end
end

0 comments on commit c45f02a

Please sign in to comment.