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

Instance Method Details

#deleteObject Also known as: del, clear



9
10
11
# File 'lib/redis/helpers/core_commands.rb', line 9

def delete
  redis.del key
end

#exists?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/redis/helpers/core_commands.rb', line 5

def exists?
  redis.exists key
end

#expire(seconds) ⇒ Object



33
34
35
# File 'lib/redis/helpers/core_commands.rb', line 33

def expire(seconds)
  redis.expire key, seconds
end

#expireat(unixtime) ⇒ Object



37
38
39
# File 'lib/redis/helpers/core_commands.rb', line 37

def expireat(unixtime)
  redis.expire key, unixtime
end

#move(dbindex) ⇒ Object



45
46
47
# File 'lib/redis/helpers/core_commands.rb', line 45

def move(dbindex)
  redis.move key, dbindex
end

#rename(name, setkey = true) ⇒ Object



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

#renamenx(name, setkey = true) ⇒ Object



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

#sort(options = {}) ⇒ Object



49
50
51
52
# File 'lib/redis/helpers/core_commands.rb', line 49

def sort(options={})
  options[:order] ||= "asc alpha"
  redis.sort(key, options)
end

#ttlObject



41
42
43
# File 'lib/redis/helpers/core_commands.rb', line 41

def ttl
  redis.ttl(@key).seconds
end

#typeObject



15
16
17
# File 'lib/redis/helpers/core_commands.rb', line 15

def type
  redis.type key
end