ruby-redis 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +9 -0
- data/README +90 -0
- data/bin/ruby-redis +12 -0
- data/bin/ruby-redis.compiled.rbc +243 -0
- data/lib/redis/bin.rb +74 -0
- data/lib/redis/bin.rbc +1325 -0
- data/lib/redis/buftok.rbc +2658 -0
- data/lib/redis/config.rb +46 -0
- data/lib/redis/config.rbc +1009 -0
- data/lib/redis/connection.rb +69 -0
- data/lib/redis/connection.rbc +1354 -0
- data/lib/redis/database.rb +109 -0
- data/lib/redis/database.rbc +2275 -0
- data/lib/redis/hashes.rb +72 -0
- data/lib/redis/hashes.rbc +1843 -0
- data/lib/redis/hiredis.rbc +658 -0
- data/lib/redis/keys.rb +165 -0
- data/lib/redis/keys.rbc +3386 -0
- data/lib/redis/lists.rb +227 -0
- data/lib/redis/lists.rbc +5241 -0
- data/lib/redis/logger.rb +81 -0
- data/lib/redis/logger.rbc +2106 -0
- data/lib/redis/protocol.rb +170 -0
- data/lib/redis/protocol.rbc +3735 -0
- data/lib/redis/pubsub.rb +153 -0
- data/lib/redis/pubsub.rbc +3447 -0
- data/lib/redis/reader.rb +164 -0
- data/lib/redis/reader.rbc +2769 -0
- data/lib/redis/send.rbc +1268 -0
- data/lib/redis/sender.rb +49 -0
- data/lib/redis/sender.rbc +1057 -0
- data/lib/redis/server.rb +62 -0
- data/lib/redis/server.rbc +1177 -0
- data/lib/redis/sets.rb +105 -0
- data/lib/redis/sets.rbc +2800 -0
- data/lib/redis/strict.rb +67 -0
- data/lib/redis/strict.rbc +1419 -0
- data/lib/redis/strings.rb +144 -0
- data/lib/redis/strings.rbc +3338 -0
- data/lib/redis/synchrony.rb +58 -0
- data/lib/redis/synchrony.rbc +1397 -0
- data/lib/redis/version.rb +7 -0
- data/lib/redis/version.rbc +180 -0
- data/lib/redis/zsets.rb +281 -0
- data/lib/redis/zsets.rbc +6596 -0
- data/lib/redis.rb +215 -0
- data/lib/redis.rbc +4391 -0
- metadata +117 -0
@@ -0,0 +1,69 @@
|
|
1
|
+
require File.expand_path '../redis', File.dirname(__FILE__)
|
2
|
+
require_relative 'database'
|
3
|
+
require_relative 'protocol'
|
4
|
+
require_relative 'server'
|
5
|
+
require_relative 'keys'
|
6
|
+
require_relative 'strings'
|
7
|
+
require_relative 'lists'
|
8
|
+
require_relative 'sets'
|
9
|
+
require_relative 'zsets'
|
10
|
+
require_relative 'hashes'
|
11
|
+
require_relative 'pubsub'
|
12
|
+
require_relative 'strict'
|
13
|
+
|
14
|
+
require 'eventmachine'
|
15
|
+
|
16
|
+
class Redis
|
17
|
+
class Connection < EventMachine::Connection
|
18
|
+
|
19
|
+
include NotStrict
|
20
|
+
include Protocol
|
21
|
+
|
22
|
+
def initialize password=nil
|
23
|
+
@password = password
|
24
|
+
@database = Redis.databases[0]
|
25
|
+
authorize unless @password
|
26
|
+
super()
|
27
|
+
end
|
28
|
+
|
29
|
+
def authorize
|
30
|
+
return if @authorized
|
31
|
+
extend Server
|
32
|
+
extend Keys
|
33
|
+
extend Strings
|
34
|
+
extend Lists
|
35
|
+
extend Sets
|
36
|
+
extend ZSets
|
37
|
+
extend Hashes
|
38
|
+
extend PubSub
|
39
|
+
@authorized = true
|
40
|
+
end
|
41
|
+
|
42
|
+
def redis_AUTH password
|
43
|
+
raise 'invalid password' unless password == @password
|
44
|
+
authorize
|
45
|
+
Response::OK
|
46
|
+
end
|
47
|
+
|
48
|
+
def redis_SELECT db_index
|
49
|
+
database = Redis.databases[redis_i db_index]
|
50
|
+
raise 'invalid DB index' unless database
|
51
|
+
@database = database
|
52
|
+
Response::OK
|
53
|
+
end
|
54
|
+
|
55
|
+
def redis_PING
|
56
|
+
Response::PONG
|
57
|
+
end
|
58
|
+
|
59
|
+
def redis_ECHO str
|
60
|
+
str
|
61
|
+
end
|
62
|
+
|
63
|
+
def redis_QUIT
|
64
|
+
send_redis Response::OK
|
65
|
+
raise CloseConnection
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|