ruby-redis 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/LICENSE +9 -0
  2. data/README +90 -0
  3. data/bin/ruby-redis +12 -0
  4. data/bin/ruby-redis.compiled.rbc +243 -0
  5. data/lib/redis/bin.rb +74 -0
  6. data/lib/redis/bin.rbc +1325 -0
  7. data/lib/redis/buftok.rbc +2658 -0
  8. data/lib/redis/config.rb +46 -0
  9. data/lib/redis/config.rbc +1009 -0
  10. data/lib/redis/connection.rb +69 -0
  11. data/lib/redis/connection.rbc +1354 -0
  12. data/lib/redis/database.rb +109 -0
  13. data/lib/redis/database.rbc +2275 -0
  14. data/lib/redis/hashes.rb +72 -0
  15. data/lib/redis/hashes.rbc +1843 -0
  16. data/lib/redis/hiredis.rbc +658 -0
  17. data/lib/redis/keys.rb +165 -0
  18. data/lib/redis/keys.rbc +3386 -0
  19. data/lib/redis/lists.rb +227 -0
  20. data/lib/redis/lists.rbc +5241 -0
  21. data/lib/redis/logger.rb +81 -0
  22. data/lib/redis/logger.rbc +2106 -0
  23. data/lib/redis/protocol.rb +170 -0
  24. data/lib/redis/protocol.rbc +3735 -0
  25. data/lib/redis/pubsub.rb +153 -0
  26. data/lib/redis/pubsub.rbc +3447 -0
  27. data/lib/redis/reader.rb +164 -0
  28. data/lib/redis/reader.rbc +2769 -0
  29. data/lib/redis/send.rbc +1268 -0
  30. data/lib/redis/sender.rb +49 -0
  31. data/lib/redis/sender.rbc +1057 -0
  32. data/lib/redis/server.rb +62 -0
  33. data/lib/redis/server.rbc +1177 -0
  34. data/lib/redis/sets.rb +105 -0
  35. data/lib/redis/sets.rbc +2800 -0
  36. data/lib/redis/strict.rb +67 -0
  37. data/lib/redis/strict.rbc +1419 -0
  38. data/lib/redis/strings.rb +144 -0
  39. data/lib/redis/strings.rbc +3338 -0
  40. data/lib/redis/synchrony.rb +58 -0
  41. data/lib/redis/synchrony.rbc +1397 -0
  42. data/lib/redis/version.rb +7 -0
  43. data/lib/redis/version.rbc +180 -0
  44. data/lib/redis/zsets.rb +281 -0
  45. data/lib/redis/zsets.rbc +6596 -0
  46. data/lib/redis.rb +215 -0
  47. data/lib/redis.rbc +4391 -0
  48. metadata +117 -0
@@ -0,0 +1,81 @@
1
+ require File.expand_path '../redis', File.dirname(__FILE__)
2
+ require 'logger'
3
+
4
+ class Redis
5
+
6
+ # Create log entry example:
7
+ # Redis.logger.notice "Server started, Redis version %s (Ruby)" % Redis::VERSION
8
+ # Change device example:
9
+ # Redis.logger config[:logfile] unless config[:logfile] == 'stdout'
10
+ def self.logger(logdev = nil, *opts)
11
+ @@logger = nil if logdev
12
+ @@logger ||= Logger.new(logdev||STDOUT, *opts)
13
+ end
14
+
15
+ # Redis levels are: DEBUG < INFO < NOTICE < WARNING
16
+ # This logger inserts support for NOTICE
17
+ class Logger < ::Logger
18
+
19
+ def initialize(logdev, *args)
20
+ super
21
+ @raw_logdev = logdev
22
+ @default_formatter = proc { |severity, datetime, progname, msg|
23
+ mark = case severity
24
+ when 'DEBUG' then '.'
25
+ when 'INFO' then '-'
26
+ when 'NOTE' then '*'
27
+ when 'WARN' then '#'
28
+ else '!'
29
+ end
30
+ "[#{Process.pid}] #{datetime.strftime '%d %b %H:%H:%S'} #{mark} #{msg}\n"
31
+ }
32
+ end
33
+
34
+ def flush
35
+ @raw_logdev.flush if @raw_logdev.respond_to? :flush
36
+ end
37
+
38
+ module Severity
39
+ # logger.rb says "max 5 char" for labels
40
+ SEV_LABEL = %w(DEBUG INFO NOTE WARN ERROR FATAL ANY)
41
+ DEBUG = 0
42
+ INFO = 1
43
+ NOTICE = 2
44
+ WARN = 3
45
+ ERROR = 4
46
+ FATAL = 5
47
+ UNKNOWN = 6
48
+ end
49
+ include Severity
50
+
51
+ def notice(progname = nil, &block)
52
+ add(NOTICE, nil, progname, &block)
53
+ end
54
+ def warn(progname = nil, &block)
55
+ add(WARN, nil, progname, &block)
56
+ end
57
+ def error(progname = nil, &block)
58
+ add(ERROR, nil, progname, &block)
59
+ end
60
+ def fatal(progname = nil, &block)
61
+ add(FATAL, nil, progname, &block)
62
+ end
63
+ def unknown(progname = nil, &block)
64
+ add(UNKNOWN, nil, progname, &block)
65
+ end
66
+
67
+ def notice?; @level <= NOTICE; end
68
+ def warn?; @level <= WARN; end
69
+ def error?; @level <= ERROR; end
70
+ def fatal?; @level <= FATAL; end
71
+
72
+ private
73
+
74
+ def format_severity(severity)
75
+ SEV_LABEL[severity] || 'ANY'
76
+ end
77
+
78
+ end
79
+
80
+
81
+ end