mingle_keyvalue_store 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mingle_keyvalue_store.rb +29 -17
  3. metadata +12 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03614bdcad32cb978d33f244920d570f3a0ad7ce
4
- data.tar.gz: 300bec550380496cdb2bd84a77e43c432fa3ad5f
3
+ metadata.gz: 49d84696711f09b6af8abf2d0d2dcab9ad900c23
4
+ data.tar.gz: fdec133312a875c06258190471b1ff3491ed7f9b
5
5
  SHA512:
6
- metadata.gz: 8fd736ac1fbde5aa64c17f28bee24338c5f52f17abe6c0c05e7066da2345d63deb4e62ef4c317151c146b00ad7821b08751c67b576204a3c5504d5f0553cfc16
7
- data.tar.gz: 8b71f1f67a926f92c00937da39b37f04e3aab6c6e6068ba1074f74d55a76c48c4195232ab46f1b9a1ad796b118aa9516cf1ce0ec88da1abeac6dffacb9c8f926
6
+ metadata.gz: bcaef1f60faad66156ba24e4fe41aef9562ee7e0786816f4358ec88f1fdde2a43040c7be79641193fcf2d33a2d7d3d22b39edd9eaeab8e179521ab906dfaaea7
7
+ data.tar.gz: 567f4ca17836fa2fb96e9087d6b48da9913f0e35d80e098c10b898e8ca61244f2aef42d1d961e43552c11ae6facfa4e4d8307ab2df23c08645e1bb71451b1bb1
@@ -3,35 +3,43 @@ require "aws"
3
3
  require "pstore"
4
4
  require "fileutils"
5
5
  require "tempfile"
6
+ require 'monitor'
6
7
 
7
8
  module Mingle
8
9
  module KeyvalueStore
9
- class PStoreBased
10
+ class PStoreBased < Monitor
10
11
  def initialize(path, namespace, key_column, value_column)
11
12
  @namespace = namespace
12
13
  @store_file = store_file(path)
13
14
  @key_column = key_column
14
15
  @value_column = value_column
15
16
  @pstore = PStore.new(@store_file)
17
+ super()
16
18
  end
17
19
 
18
20
  def [](store_key)
19
- @pstore.transaction { @pstore[store_key] }
21
+ synchronize do
22
+ @pstore.transaction { @pstore[store_key] }
23
+ end
20
24
  end
21
25
 
22
26
  def []=(store_key, value)
23
27
  raise ArgumentError, "Value must be String" unless value.is_a?(String)
24
- @pstore.transaction do
25
- @pstore["all_names"] ||= []
26
- @pstore["all_names"] = (@pstore["all_names"] + [store_key]).uniq
27
- @pstore[store_key] = value
28
+ synchronize do
29
+ @pstore.transaction do
30
+ @pstore["all_names"] ||= []
31
+ @pstore["all_names"] = (@pstore["all_names"] + [store_key]).uniq
32
+ @pstore[store_key] = value
33
+ end
28
34
  end
29
35
  end
30
36
 
31
37
  def delete(store_key)
32
- @pstore.transaction do
33
- @pstore["all_names"].delete_if {|name| name == store_key}
34
- @pstore.delete(store_key)
38
+ synchronize do
39
+ @pstore.transaction do
40
+ @pstore["all_names"].delete_if {|name| name == store_key}
41
+ @pstore.delete(store_key)
42
+ end
35
43
  end
36
44
  nil
37
45
  end
@@ -43,17 +51,21 @@ module Mingle
43
51
  end
44
52
 
45
53
  def names
46
- @pstore.transaction { @pstore["all_names"] || [] }
54
+ synchronize do
55
+ @pstore.transaction { @pstore["all_names"] || [] }
56
+ end
47
57
  end
48
58
 
49
59
  def all_items
50
- @pstore.transaction do
51
- return [] unless @pstore["all_names"]
52
- @pstore["all_names"].map do |name|
53
- {
54
- @key_column.to_s => name,
55
- @value_column.to_s => @pstore[name]
56
- }
60
+ synchronize do
61
+ @pstore.transaction do
62
+ return [] unless @pstore["all_names"]
63
+ @pstore["all_names"].map do |name|
64
+ {
65
+ @key_column.to_s => name,
66
+ @value_column.to_s => @pstore[name]
67
+ }
68
+ end
57
69
  end
58
70
  end
59
71
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mingle_keyvalue_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian
@@ -9,11 +9,10 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-04 00:00:00.000000000 Z
12
+ date: 2016-01-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: aws-sdk
16
- version_requirements: !ruby/object:Gem::Requirement
15
+ requirement: !ruby/object:Gem::Requirement
17
16
  requirements:
18
17
  - - ~>
19
18
  - !ruby/object:Gem::Version
@@ -21,7 +20,10 @@ dependencies:
21
20
  - - '>='
22
21
  - !ruby/object:Gem::Version
23
22
  version: 1.11.3
24
- requirement: !ruby/object:Gem::Requirement
23
+ name: aws-sdk
24
+ prerelease: false
25
+ type: :runtime
26
+ version_requirements: !ruby/object:Gem::Requirement
25
27
  requirements:
26
28
  - - ~>
27
29
  - !ruby/object:Gem::Version
@@ -29,22 +31,20 @@ dependencies:
29
31
  - - '>='
30
32
  - !ruby/object:Gem::Version
31
33
  version: 1.11.3
32
- prerelease: false
33
- type: :runtime
34
34
  - !ruby/object:Gem::Dependency
35
- name: rake
36
- version_requirements: !ruby/object:Gem::Requirement
35
+ requirement: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - '>='
39
38
  - !ruby/object:Gem::Version
40
39
  version: '0'
41
- requirement: !ruby/object:Gem::Requirement
40
+ name: rake
41
+ prerelease: false
42
+ type: :development
43
+ version_requirements: !ruby/object:Gem::Requirement
42
44
  requirements:
43
45
  - - '>='
44
46
  - !ruby/object:Gem::Version
45
47
  version: '0'
46
- prerelease: false
47
- type: :development
48
48
  description: A key value store implentation that uses DynamoDB or Pstore underneath.
49
49
  email:
50
50
  - reginaldthedog@gmail.com