Sha256: ba0182c846b0a86cb942c55a09c27521b00ab8765b4c4e17b604515cace80f1c
Contents?: true
Size: 1.92 KB
Versions: 2
Compression:
Stored size: 1.92 KB
Contents
class ActiveOrm::Redis::String < ActiveOrm::Redis def self.find(key) value = client.get(normalize_key(key)) value = metamorph(value) if evaluate? value end def self.find_each(*args) args = stringify_keys(args) value = client.mget(args) value = metamorph(value) if evaluate? value end def self.length(key) client.strlen(normalize_key(key)) end def self.split(key, start, finish) client.getrange(normalize_key(key), start, finish) end def self.create(key, value, opts={}) client.set(normalize_key(key), value, opts) end def self.create!(key, value) client.setnx(normalize_key(key), value) end def self.create_each(*args) args = stringify_keys(args) client.mset(args) end def self.create_each!(*args) args = stringify_keys(args) client.msetnx(args) end def self.create_until(key, value, seconds, format=:seconds) seconds?(format) ? client.setex(normalize_key(key), seconds, value) : client.psetex(normalize_key(key), seconds, value) end def self.append(key, value) client.append(normalize_key(key), value) end def self.replace(key, value, offset) client.setrange(normalize_key(key), offset, value) end def self.decrement(key, value=1) (value == 1) ? client.decr(normalize_key(key)) : client.decrby(normalize_key(key), value) end def self.increment(key, value=1) if value.is_a?(Float) client.incrbyfloat(normalize_key(key), value) else (value == 1) ? client.incr(normalize_key(key)) : client.incrby(normalize_key(key), value) end end def self.reset(key, value=0) client.getset(normalize_key(key), value) end def self.bit_count(key, start=0, finish=-1) client.bitcount(normalize_key(key), start, finish) end def self.get_bit(key, offset) client.getbit(normalize_key(key), offset) end def self.set_bit(key, offset, bit) client.setbit(normalize_key(key), offset, bit) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_orm-2.4.0 | lib/active_orm/redis/string.rb |
active_orm-2.3.0 | lib/active_orm/redis/string.rb |