picky 2.5.1 → 2.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,19 +9,28 @@ module Internals
9
9
  # Writes the hash into Redis.
10
10
  #
11
11
  def dump hash
12
+ clear
12
13
  hash.each_pair do |key, values|
13
14
  redis_key = "#{namespace}:#{key}"
14
15
  i = 0
15
- backend.multi do
16
- backend.del redis_key
17
-
18
- values.each do |value|
19
- i += 1
20
- backend.zadd redis_key, i, value
21
- end
16
+ values.each do |value|
17
+ i += 1
18
+ backend.zadd redis_key, i, value
22
19
  end
23
20
  end
24
21
  end
22
+
23
+ # Clear the index for this list.
24
+ #
25
+ # Note: Perhaps we can use a server only command.
26
+ # This is not the optimal way to do it.
27
+ #
28
+ def clear
29
+ redis_key = "#{namespace}:*"
30
+ backend.keys(redis_key).each do |key|
31
+ backend.del key
32
+ end
33
+ end
25
34
 
26
35
  # Get a collection.
27
36
  #
@@ -11,11 +11,17 @@ module Internals
11
11
  # Note: We could use multi, but it did not help.
12
12
  #
13
13
  def dump hash
14
- redis = backend
14
+ clear
15
15
  hash.each_pair do |key, value|
16
- redis.hset namespace, key, value
16
+ backend.hset namespace, key, value
17
17
  end
18
18
  end
19
+
20
+ # Clears the hash.
21
+ #
22
+ def clear
23
+ backend.del namespace
24
+ end
19
25
 
20
26
  # Get a collection.
21
27
  #
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: picky
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.5.1
5
+ version: 2.5.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Florian Hanke
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-02 00:00:00 +10:00
13
+ date: 2011-07-03 00:00:00 +10:00
14
14
  default_executable: picky
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -32,7 +32,7 @@ dependencies:
32
32
  requirements:
33
33
  - - "="
34
34
  - !ruby/object:Gem::Version
35
- version: 2.5.1
35
+ version: 2.5.2
36
36
  type: :development
37
37
  version_requirements: *id002
38
38
  description: Fast Ruby semantic text search engine with comfortable single field interface.