bloomfilter-rb 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -2,22 +2,22 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  bloomfilter-rb (2.0.0)
5
- redis (>= 2.1.1)
5
+ redis
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
10
  diff-lcs (1.1.2)
11
11
  rake (0.8.7)
12
- redis (2.1.1)
13
- rspec (2.3.0)
14
- rspec-core (~> 2.3.0)
15
- rspec-expectations (~> 2.3.0)
16
- rspec-mocks (~> 2.3.0)
17
- rspec-core (2.3.1)
18
- rspec-expectations (2.3.0)
12
+ redis (2.2.0)
13
+ rspec (2.5.0)
14
+ rspec-core (~> 2.5.0)
15
+ rspec-expectations (~> 2.5.0)
16
+ rspec-mocks (~> 2.5.0)
17
+ rspec-core (2.5.1)
18
+ rspec-expectations (2.5.0)
19
19
  diff-lcs (~> 1.1.2)
20
- rspec-mocks (2.3.0)
20
+ rspec-mocks (2.5.0)
21
21
 
22
22
  PLATFORMS
23
23
  ruby
@@ -25,5 +25,4 @@ PLATFORMS
25
25
  DEPENDENCIES
26
26
  bloomfilter-rb!
27
27
  rake
28
- redis (>= 2.1.1)
29
28
  rspec
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.description = s.summary
14
14
  s.rubyforge_project = "bloomfilter-rb"
15
15
 
16
- s.add_dependency "redis", ">= 2.1.1"
16
+ s.add_dependency "redis"
17
17
  s.add_development_dependency "rspec"
18
18
  s.add_development_dependency "rake"
19
19
 
@@ -7,28 +7,32 @@ module BloomFilter
7
7
  :hashes => 4,
8
8
  :seed => Time.now.to_i,
9
9
  :namespace => 'redis',
10
- :eager => true,
10
+ :eager => false,
11
11
  :server => {}
12
12
  }.merge opts
13
13
  @db = ::Redis.new(@opts[:server])
14
14
 
15
15
  if @opts[:eager]
16
- # allocate the memory immediately
17
- @db.setbit @opts[:namespace], @opts[:size], 1
18
- @db.setbit @opts[:namespace], @opts[:size], 0
16
+ @db.setbit @opts[:namespace], @opts[:size]+1, 1
19
17
  end
20
18
  end
21
19
 
22
20
  def insert(key, ttl=nil)
23
- indexes_for(key) { |idx| @db.setbit @opts[:namespace], idx, 1 }
21
+ @db.pipelined do
22
+ indexes_for(key) { |idx| @db.setbit @opts[:namespace], idx, 1 }
23
+ end
24
24
  end
25
25
  alias :[]= :insert
26
26
 
27
27
  def include?(*keys)
28
28
  keys.each do |key|
29
- indexes_for(key) do |idx|
30
- return false if @db.getbit(@opts[:namespace], idx).zero?
29
+ result = @db.pipelined do
30
+ indexes_for(key) do |idx|
31
+ @db.getbit(@opts[:namespace], idx)
32
+ end
31
33
  end
34
+
35
+ return false if result.include?(0)
32
36
  end
33
37
 
34
38
  true
@@ -36,8 +40,10 @@ module BloomFilter
36
40
  alias :key? :include?
37
41
 
38
42
  def delete(key)
39
- indexes_for(key) do |idx|
40
- @db.setbit @opts[:namespace], idx, 0
43
+ @db.pipelined do
44
+ indexes_for(key) do |idx|
45
+ @db.setbit @opts[:namespace], idx, 0
46
+ end
41
47
  end
42
48
  end
43
49
 
@@ -1,3 +1,3 @@
1
1
  module BloomFilter
2
- VERSION = "2.0.0"
3
- end
2
+ VERSION = "2.1.0"
3
+ end
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bloomfilter-rb
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 2
7
- - 0
8
- - 0
9
- version: 2.0.0
4
+ prerelease:
5
+ version: 2.1.0
10
6
  platform: ruby
11
7
  authors:
12
8
  - Ilya Grigorik
@@ -15,7 +11,7 @@ autorequire:
15
11
  bindir: bin
16
12
  cert_chain: []
17
13
 
18
- date: 2011-01-05 00:00:00 -05:00
14
+ date: 2011-03-30 00:00:00 -04:00
19
15
  default_executable:
20
16
  dependencies:
21
17
  - !ruby/object:Gem::Dependency
@@ -26,11 +22,7 @@ dependencies:
26
22
  requirements:
27
23
  - - ">="
28
24
  - !ruby/object:Gem::Version
29
- segments:
30
- - 2
31
- - 1
32
- - 1
33
- version: 2.1.1
25
+ version: "0"
34
26
  type: :runtime
35
27
  version_requirements: *id001
36
28
  - !ruby/object:Gem::Dependency
@@ -41,8 +33,6 @@ dependencies:
41
33
  requirements:
42
34
  - - ">="
43
35
  - !ruby/object:Gem::Version
44
- segments:
45
- - 0
46
36
  version: "0"
47
37
  type: :development
48
38
  version_requirements: *id002
@@ -54,8 +44,6 @@ dependencies:
54
44
  requirements:
55
45
  - - ">="
56
46
  - !ruby/object:Gem::Version
57
- segments:
58
- - 0
59
47
  version: "0"
60
48
  type: :development
61
49
  version_requirements: *id003
@@ -108,21 +96,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
96
  requirements:
109
97
  - - ">="
110
98
  - !ruby/object:Gem::Version
111
- segments:
112
- - 0
113
99
  version: "0"
114
100
  required_rubygems_version: !ruby/object:Gem::Requirement
115
101
  none: false
116
102
  requirements:
117
103
  - - ">="
118
104
  - !ruby/object:Gem::Version
119
- segments:
120
- - 0
121
105
  version: "0"
122
106
  requirements: []
123
107
 
124
108
  rubyforge_project: bloomfilter-rb
125
- rubygems_version: 1.3.7
109
+ rubygems_version: 1.6.2
126
110
  signing_key:
127
111
  specification_version: 3
128
112
  summary: Counting Bloom Filter implemented in Ruby