redis 2.0.0.rc3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'rake/gempackagetask'
3
3
  require 'rake/testtask'
4
- require 'tasks/redis.tasks'
5
4
 
6
5
  $:.unshift File.join(File.dirname(__FILE__), 'lib')
7
6
  require 'redis'
@@ -9,7 +8,7 @@ require 'redis'
9
8
  GEM = 'redis'
10
9
  GEM_NAME = 'redis'
11
10
  GEM_VERSION = Redis::VERSION
12
- AUTHORS = ['Ezra Zygmuntowicz', 'Taylor Weibley', 'Matthew Clark', 'Brian McKinney', 'Salvatore Sanfilippo', 'Luca Guidi']
11
+ AUTHORS = ['Ezra Zygmuntowicz', 'Taylor Weibley', 'Matthew Clark', 'Brian McKinney', 'Salvatore Sanfilippo', 'Luca Guidi', 'Michel Martens', 'Damian Janowski']
13
12
  EMAIL = "ez@engineyard.com"
14
13
  HOMEPAGE = "http://github.com/ezmobius/redis-rb"
15
14
  SUMMARY = "Ruby client library for Redis, the key value storage server"
@@ -64,7 +63,7 @@ end
64
63
 
65
64
  desc "install the gem locally"
66
65
  task :install => [:package] do
67
- sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
66
+ sh %{gem install pkg/#{GEM}-#{GEM_VERSION}}
68
67
  end
69
68
 
70
69
  desc "create a gemspec file"
@@ -1,7 +1,7 @@
1
1
  require 'socket'
2
2
 
3
3
  class Redis
4
- VERSION = "2.0.0.rc3"
4
+ VERSION = "2.0.0"
5
5
 
6
6
  class ProtocolError < RuntimeError
7
7
  def initialize(reply_type)
@@ -69,6 +69,14 @@ class Redis
69
69
  @client.call(:mget, *keys)
70
70
  end
71
71
 
72
+ def append(key, value)
73
+ @client.call(:append, key, value)
74
+ end
75
+
76
+ def substr(key, start, stop)
77
+ @client.call(:substr, key, start, stop)
78
+ end
79
+
72
80
  def hgetall(key)
73
81
  Hash[*@client.call(:hgetall, key)]
74
82
  end
@@ -225,6 +233,14 @@ class Redis
225
233
  _bool @client.call(:zadd, key, score, member)
226
234
  end
227
235
 
236
+ def zrank(key, member)
237
+ @client.call(:zrank, key, member)
238
+ end
239
+
240
+ def zrevrank(key, member)
241
+ @client.call(:zrevrank, key, member)
242
+ end
243
+
228
244
  def zincrby(key, increment, member)
229
245
  @client.call(:zincrby, key, increment, member)
230
246
  end
@@ -263,7 +279,7 @@ class Redis
263
279
  end
264
280
 
265
281
  def zremrangebyrank(key, start, stop)
266
- @client.call(:zremrangebyscore, key, start, stop)
282
+ @client.call(:zremrangebyrank, key, start, stop)
267
283
  end
268
284
 
269
285
  def zscore(key, member)
@@ -274,12 +290,22 @@ class Redis
274
290
  _bool @client.call(:zrem, key, member)
275
291
  end
276
292
 
277
- def zinter(destination, keys)
278
- @client.call(:zinter, destination, keys.size, *keys)
293
+ def zinterstore(destination, keys, options = {})
294
+ command = CommandOptions.new(options) do |c|
295
+ c.splat :weights
296
+ c.value :aggregate
297
+ end
298
+
299
+ @client.call(:zinterstore, destination, keys.size, *(keys + command.to_a))
279
300
  end
280
301
 
281
- def zunion(destination, keys)
282
- @client.call(:zunion, destination, keys.size, *keys)
302
+ def zunionstore(destination, keys, options = {})
303
+ command = CommandOptions.new(options) do |c|
304
+ c.splat :weights
305
+ c.value :aggregate
306
+ end
307
+
308
+ @client.call(:zunionstore, destination, keys.size, *(keys + command.to_a))
283
309
  end
284
310
 
285
311
  def move(key, db)
@@ -322,6 +348,10 @@ class Redis
322
348
  @client.call(:hmset, key, *attrs)
323
349
  end
324
350
 
351
+ def mapped_hmset(key, hash)
352
+ hmset(key, *hash.to_a.flatten)
353
+ end
354
+
325
355
  def hlen(key)
326
356
  @client.call(:hlen, key)
327
357
  end
@@ -330,6 +360,10 @@ class Redis
330
360
  @client.call(:hvals, key)
331
361
  end
332
362
 
363
+ def hincrby(key, field, increment)
364
+ @client.call(:hincrby, key, field, increment)
365
+ end
366
+
333
367
  def discard
334
368
  @client.call(:discard)
335
369
  end
@@ -338,8 +372,8 @@ class Redis
338
372
  _bool @client.call(:hexists, key, field)
339
373
  end
340
374
 
341
- def monitor
342
- raise NotImplementedError
375
+ def monitor(&block)
376
+ @client.call_loop(:monitor, &block)
343
377
  end
344
378
 
345
379
  def [](key)
@@ -439,11 +473,12 @@ class Redis
439
473
 
440
474
  begin
441
475
  yield(self)
442
- exec
443
476
  rescue Exception => e
444
477
  discard
445
478
  raise e
446
479
  end
480
+
481
+ exec
447
482
  end
448
483
 
449
484
  def publish(channel, message)
@@ -126,6 +126,14 @@ class Redis
126
126
  get(key)
127
127
  end
128
128
 
129
+ def append(key, value)
130
+ node_for(key).append(key, value)
131
+ end
132
+
133
+ def substr(key, start, stop)
134
+ node_for(key).substr(key, start, stop)
135
+ end
136
+
129
137
  def []=(key,value)
130
138
  set(key, value)
131
139
  end
@@ -346,15 +354,15 @@ class Redis
346
354
  node_for(key).zscore(key, member)
347
355
  end
348
356
 
349
- def zinter(destination, keys)
350
- ensure_same_node(:zinter, destination, *keys) do |node|
351
- node.zinter(destination, keys)
357
+ def zinterstore(destination, keys, options = {})
358
+ ensure_same_node(:zinterstore, destination, *keys) do |node|
359
+ node.zinterstore(destination, keys, options)
352
360
  end
353
361
  end
354
362
 
355
- def zunion(destination, keys)
356
- ensure_same_node(:zunion, destination, *keys) do |node|
357
- node.zunion(destination, keys)
363
+ def zunionstore(destination, keys, options = {})
364
+ ensure_same_node(:zunionstore, destination, *keys) do |node|
365
+ node.zunionstore(destination, keys, options)
358
366
  end
359
367
  end
360
368
 
@@ -394,6 +402,10 @@ class Redis
394
402
  node_for(key).hmset(key, *attrs)
395
403
  end
396
404
 
405
+ def hincrby(key, field, increment)
406
+ node_for(key).hincrby(key, field, increment)
407
+ end
408
+
397
409
  def sort(key, options = {})
398
410
  keys = [key, options[:by], options[:store], *Array(options[:get])].compact
399
411
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: true
4
+ hash: 15
5
+ prerelease: false
5
6
  segments:
6
7
  - 2
7
8
  - 0
8
9
  - 0
9
- - rc3
10
- version: 2.0.0.rc3
10
+ version: 2.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ezra Zygmuntowicz
@@ -16,11 +16,13 @@ authors:
16
16
  - Brian McKinney
17
17
  - Salvatore Sanfilippo
18
18
  - Luca Guidi
19
+ - Michel Martens
20
+ - Damian Janowski
19
21
  autorequire: redis
20
22
  bindir: bin
21
23
  cert_chain: []
22
24
 
23
- date: 2010-05-06 00:00:00 -03:00
25
+ date: 2010-05-14 00:00:00 -03:00
24
26
  default_executable:
25
27
  dependencies: []
26
28
 
@@ -36,16 +38,13 @@ files:
36
38
  - LICENSE
37
39
  - README.markdown
38
40
  - Rakefile
39
- - lib/edis.rb
40
41
  - lib/redis/client.rb
41
42
  - lib/redis/compat.rb
42
43
  - lib/redis/distributed.rb
43
44
  - lib/redis/hash_ring.rb
44
45
  - lib/redis/pipeline.rb
45
- - lib/redis/raketasks.rb
46
46
  - lib/redis/subscribe.rb
47
47
  - lib/redis.rb
48
- - tasks/redis.tasks.rb
49
48
  has_rdoc: true
50
49
  homepage: http://github.com/ezmobius/redis-rb
51
50
  licenses: []
@@ -56,25 +55,27 @@ rdoc_options: []
56
55
  require_paths:
57
56
  - lib
58
57
  required_ruby_version: !ruby/object:Gem::Requirement
58
+ none: false
59
59
  requirements:
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
+ hash: 3
62
63
  segments:
63
64
  - 0
64
65
  version: "0"
65
66
  required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
66
68
  requirements:
67
- - - ">"
69
+ - - ">="
68
70
  - !ruby/object:Gem::Version
71
+ hash: 3
69
72
  segments:
70
- - 1
71
- - 3
72
- - 1
73
- version: 1.3.1
73
+ - 0
74
+ version: "0"
74
75
  requirements: []
75
76
 
76
77
  rubyforge_project:
77
- rubygems_version: 1.3.6
78
+ rubygems_version: 1.3.7
78
79
  signing_key:
79
80
  specification_version: 3
80
81
  summary: Ruby client library for Redis, the key value storage server
@@ -1,3 +0,0 @@
1
- # This file allows for the running of redis-rb with a nice
2
- # command line look-and-feel: irb -rubygems -redis foo.rb
3
- require 'redis'
@@ -1 +0,0 @@
1
- require File.dirname(__FILE__) + "/../../tasks/redis.tasks"
@@ -1,140 +0,0 @@
1
- # Inspired by rabbitmq.rake the Redbox project at http://github.com/rick/redbox/tree/master
2
- require 'rake'
3
- require 'fileutils'
4
- require 'open-uri'
5
-
6
- class RedisRunner
7
-
8
- def self.redisdir
9
- "/tmp/redis/"
10
- end
11
-
12
- def self.redisconfdir
13
- '/etc/redis.conf'
14
- end
15
-
16
- def self.dtach_socket
17
- '/tmp/redis.dtach'
18
- end
19
-
20
- # Just check for existance of dtach socket
21
- def self.running?
22
- File.exists? dtach_socket
23
- end
24
-
25
- def self.start
26
- puts 'Detach with Ctrl+\ Re-attach with rake redis:attach'
27
- sleep 3
28
- exec "dtach -A #{dtach_socket} redis-server #{redisconfdir}"
29
- end
30
-
31
- def self.start_detached
32
- system "dtach -n #{dtach_socket} redis-server #{redisconfdir}"
33
- end
34
-
35
- def self.attach
36
- exec "dtach -a #{dtach_socket}"
37
- end
38
-
39
- def self.stop
40
- system 'echo "SHUTDOWN" | nc localhost 6379'
41
- end
42
-
43
- end
44
-
45
- namespace :redis do
46
-
47
- desc 'About redis'
48
- task :about do
49
- puts "\nSee http://code.google.com/p/redis/ for information about redis.\n\n"
50
- end
51
-
52
- desc 'Start redis'
53
- task :start do
54
- RedisRunner.start
55
- end
56
-
57
- desc 'Stop redis'
58
- task :stop do
59
- RedisRunner.stop
60
- end
61
-
62
- desc 'Restart redis'
63
- task :restart do
64
- RedisRunner.stop
65
- RedisRunner.start
66
- end
67
-
68
- desc 'Attach to redis dtach socket'
69
- task :attach do
70
- RedisRunner.attach
71
- end
72
-
73
- desc 'Install the lastest verison of Redis from Github (requires git, duh)'
74
- task :install => [:about, :download, :make] do
75
- %w(redis-benchmark redis-cli redis-server).each do |bin|
76
- sh "sudo cp /tmp/redis/#{bin} /usr/bin/"
77
- end
78
-
79
- puts "Installed redis-benchmark, redis-cli and redis-server to /usr/bin/"
80
-
81
- unless File.exists?('/etc/redis.conf')
82
- sh 'sudo cp /tmp/redis/redis.conf /etc/'
83
- puts "Installed redis.conf to /etc/ \n You should look at this file!"
84
- end
85
- end
86
-
87
- task :make do
88
- sh "cd #{RedisRunner.redisdir} && make clean"
89
- sh "cd #{RedisRunner.redisdir} && make"
90
- end
91
-
92
- desc "Download package"
93
- task :download do
94
- sh 'rm -rf /tmp/redis/' if File.exists?("#{RedisRunner.redisdir}/.svn")
95
- sh 'git clone git://github.com/antirez/redis.git /tmp/redis' unless File.exists?(RedisRunner.redisdir)
96
-
97
- if File.exists?("#{RedisRunner.redisdir}/.git")
98
- arguments = ENV['COMMIT'].nil? ? "pull" : "reset --hard #{ENV['COMMIT']}"
99
- sh "cd #{RedisRunner.redisdir} && git #{arguments}"
100
- end
101
- end
102
-
103
- desc "Open an IRb session"
104
- task :console do
105
- RedisRunner.start_detached
106
- system "irb -I lib -I extra -r redis.rb"
107
- RedisRunner.stop
108
- end
109
- end
110
-
111
- namespace :dtach do
112
-
113
- desc 'About dtach'
114
- task :about do
115
- puts "\nSee http://dtach.sourceforge.net/ for information about dtach.\n\n"
116
- end
117
-
118
- desc 'Install dtach 0.8 from source'
119
- task :install => [:about] do
120
-
121
- Dir.chdir('/tmp/')
122
- unless File.exists?('/tmp/dtach-0.8.tar.gz')
123
- require 'net/http'
124
-
125
- url = 'http://downloads.sourceforge.net/project/dtach/dtach/0.8/dtach-0.8.tar.gz'
126
- open('/tmp/dtach-0.8.tar.gz', 'wb') do |file| file.write(open(url).read) end
127
- end
128
-
129
- unless File.directory?('/tmp/dtach-0.8')
130
- system('tar xzf dtach-0.8.tar.gz')
131
- end
132
-
133
- Dir.chdir('/tmp/dtach-0.8/')
134
- sh 'cd /tmp/dtach-0.8/ && ./configure && make'
135
- sh 'sudo cp /tmp/dtach-0.8/dtach /usr/bin/'
136
-
137
- puts 'Dtach successfully installed to /usr/bin.'
138
- end
139
- end
140
-