Module: Redis::Server

Defined in:
lib/redis/server.rb

Instance Method Summary collapse

Instance Method Details

#redis_DBSIZEObject



17
18
19
# File 'lib/redis/server.rb', line 17

def redis_DBSIZE
  @database.size
end

#redis_DEBUG(type, key = nil) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/redis/server.rb', line 21

def redis_DEBUG type, key=nil
  if type.upcase == 'OBJECT'
    "#{@database[key].class}"
    value = @database[key]
    # encoding values are meaningless, they make tcl tests pass
    # and don't forget they need a trailing space
    if String === value
      "Value #{value.class}:#{value.object_id} encoding:raw encoding:int "
    elsif Numeric === value
      "Value #{value.class}:#{value.object_id} encoding:int "
    elsif Array === value
      "Value #{value.class}:#{value.object_id} encoding:ziplist encoding:linkedlist "
    elsif Hash === value
      "Value #{value.class}:#{value.object_id} encoding:zipmap encoding:hashtable "
    elsif Set === value
      "Value #{value.class}:#{value.object_id} encoding:intset encoding:hashtable "
    else
      "Value #{value.class}:#{value.object_id}"
    end
  elsif type.upcase == 'RELOAD'
    "TODO: what is reload"
  else
    raise 'not supported'
  end
end

#redis_FLUSHALLObject



10
11
12
13
14
15
# File 'lib/redis/server.rb', line 10

def redis_FLUSHALL
  @databases.each do |database|
    database.clear
  end
  :'+OK'
end

#redis_FLUSHDBObject



5
6
7
8
# File 'lib/redis/server.rb', line 5

def redis_FLUSHDB
  @database.clear
  :'+OK'
end

#redis_INFOObject



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/redis/server.rb', line 47

def redis_INFO
  [
    "redis_version:%s\r\n",
    "redis_git_sha1:%s\r\n",
    "redis_git_dirty:%d\r\n",
  ].join % [
    Redis::VERSION,
    "Ruby",
    1,
  ]
end