Class: Redrecord

Inherits:
Object
  • Object
show all
Defined in:
lib/redrecord.rb

Defined Under Namespace

Modules: Model

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.enabledObject

Returns the value of attribute enabled.


7
8
9
# File 'lib/redrecord.rb', line 7

def enabled
  @enabled
end

.redisObject

Returns the value of attribute redis.


7
8
9
# File 'lib/redrecord.rb', line 7

def redis
  @redis
end

.timeoutObject

Returns the value of attribute timeout.


7
8
9
# File 'lib/redrecord.rb', line 7

def timeout
  @timeout
end

.write_onlyObject

Returns the value of attribute write_only.


7
8
9
# File 'lib/redrecord.rb', line 7

def write_only
  @write_only
end

Class Method Details

.is_marshalled?(str) ⇒ Boolean

Returns:

  • (Boolean)

11
12
13
# File 'lib/redrecord.rb', line 11

def is_marshalled?(str)
  Marshal.dump(nil)[0,2] == str[0,2]
end

.redis_op(op, *args) ⇒ Object


14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/redrecord.rb', line 14

def redis_op(op, *args)
  if @enabled
    begin
      Timeout.timeout(@timeout || 15) do
        redis.send(op, *args)
      end
    rescue Exception => e
      STDERR.puts "Redrecord: Disabling redis due to exception (#{e})"
      @enabled = false
    end
  end
end

.update_queueObject


8
9
10
# File 'lib/redrecord.rb', line 8

def update_queue
  Thread.current[:redrecord_update_queue] ||= []
end