Class: SlicedRedis

Inherits:
Object
  • Object
show all
Defined in:
lib/sliced_redis.rb,
lib/sliced_redis/version.rb

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.chunked_append(redis, key, value) ⇒ Object

Append value to the given key in 50kb chunks.



21
22
23
24
25
# File 'lib/sliced_redis.rb', line 21

def chunked_append( redis, key, value )
  value.scan( /.{1,51200}/ ) do |chunk|
    redis.append key, chunk
  end
end

.set(redis, key, value) ⇒ Object



5
6
7
8
9
10
# File 'lib/sliced_redis.rb', line 5

def set( redis, key, value )
  redis.multi do
    redis.del key
    chunked_append redis, key, value
  end
end

.setex(redis, key, expiration, value) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/sliced_redis.rb', line 12

def setex( redis, key, expiration, value )
  redis.multi do
    redis.del key
    chunked_append redis, key, value
    redis.expire key, expiration
  end
end