class Rudis::Structure

Public Instance Methods

default_options() click to toggle source
# File lib/rudis/structure.rb, line 7
def default_options
  {:type => DefaultType}
end
del() click to toggle source
# File lib/rudis/structure.rb, line 16
def del
  redis.del(key)
end
Also aliased as: delete!
delete!()
Alias for: del
exist?()
Alias for: exists?
exists?() click to toggle source
# File lib/rudis/structure.rb, line 11
def exists?
  redis.exists(key)
end
Also aliased as: exist?
expire(time) click to toggle source
# File lib/rudis/structure.rb, line 30
def expire(time)
  redis.expire(key, time)
end
expire_at(time) click to toggle source
# File lib/rudis/structure.rb, line 34
def expire_at(time)
  redis.expire_at(key, time)
end
redis_type() click to toggle source
# File lib/rudis/structure.rb, line 26
def redis_type
  redis.type(key)
end
rename(new_key) click to toggle source
# File lib/rudis/structure.rb, line 21
def rename(new_key)
  redis.rename(key, self.class.key(new_key))
  @key = new_key
end
ttl() click to toggle source
# File lib/rudis/structure.rb, line 38
def ttl
  redis.ttl(key)
end
type() click to toggle source
# File lib/rudis/structure.rb, line 3
def type
  @options[:type]
end
watch(tries=0) click to toggle source
# File lib/rudis/structure.rb, line 42
def watch(tries=0)
  return redis.watch(key) unless block_given?

  begin
    redis.watch(key)
    c = 0
    while yield.nil? && (tries==0 || (c+=1) <= tries)
      puts "Optimistic lock failed for #{key}, retrying #{c} time(s)"
    end
  ensure
    redis.unwatch(key)
  end
end