Module: Redis::Helpers::CoreCommands
- Included in:
- Counter, Redis::HashKey, List, Set, SortedSet, Value
- Defined in:
- lib/redis/helpers/core_commands.rb
Overview
These are core commands that all types share (rename, etc)
Instance Method Summary (collapse)
- - (Object) delete (also: #del, #clear)
- - (Boolean) exists?
- - (Object) expire(seconds)
- - (Object) expireat(unixtime)
- - (Object) move(dbindex)
- - (Object) persist
- - (Object) rename(name, setkey = true)
- - (Object) renamenx(name, setkey = true)
- - (Object) sort(options = {})
- - (Object) ttl
- - (Object) type
Instance Method Details
- (Object) delete Also known as: del, clear
9 10 11 |
# File 'lib/redis/helpers/core_commands.rb', line 9 def delete redis.del key end |
- (Boolean) exists?
5 6 7 |
# File 'lib/redis/helpers/core_commands.rb', line 5 def exists? redis.exists key end |
- (Object) expire(seconds)
33 34 35 |
# File 'lib/redis/helpers/core_commands.rb', line 33 def expire(seconds) redis.expire key, seconds end |
- (Object) expireat(unixtime)
37 38 39 |
# File 'lib/redis/helpers/core_commands.rb', line 37 def expireat(unixtime) redis.expireat key, unixtime end |
- (Object) move(dbindex)
49 50 51 |
# File 'lib/redis/helpers/core_commands.rb', line 49 def move(dbindex) redis.move key, dbindex end |
- (Object) persist
41 42 43 |
# File 'lib/redis/helpers/core_commands.rb', line 41 def persist redis.persist key end |
- (Object) rename(name, setkey = true)
19 20 21 22 23 24 |
# File 'lib/redis/helpers/core_commands.rb', line 19 def rename(name, setkey=true) dest = name.is_a?(self.class) ? name.key : name ret = redis.rename key, dest @key = dest if ret && setkey ret end |
- (Object) renamenx(name, setkey = true)
26 27 28 29 30 31 |
# File 'lib/redis/helpers/core_commands.rb', line 26 def renamenx(name, setkey=true) dest = name.is_a?(self.class) ? name.key : name ret = redis.renamenx key, dest @key = dest if ret && setkey ret end |
- (Object) sort(options = {})
53 54 55 56 |
# File 'lib/redis/helpers/core_commands.rb', line 53 def sort(={}) [:order] = "asc alpha" if .keys.count == 0 # compat with Ruby redis.sort(key, ) end |
- (Object) ttl
45 46 47 |
# File 'lib/redis/helpers/core_commands.rb', line 45 def ttl redis.ttl(@key) end |
- (Object) type
15 16 17 |
# File 'lib/redis/helpers/core_commands.rb', line 15 def type redis.type key end |