dkastner-moneta 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,33 +25,35 @@ module Moneta
25
25
 
26
26
  def migrate
27
27
  unless Store.table_exists?
28
- Store.connection.create_table Store.table_name, :id => false do |t|
29
- t.string 'key', :primary => :true
28
+ Store.connection.create_table Store.table_name do |t|
29
+ t.string 'key_name', :primary => :true
30
30
  t.string 'value'
31
31
  end
32
32
  end
33
33
  end
34
34
 
35
35
  def key?(key)
36
- record = Store.find_by_key key_for(key)
36
+ record = Store.find_by_key_name key_for(key)
37
37
  !record.nil?
38
38
  end
39
39
 
40
40
  def [](key)
41
- record = Store.find_by_key key_for(key)
41
+ record = Store.find_by_key_name key_for(key)
42
42
  record ? deserialize(record.value) : nil
43
43
  end
44
44
 
45
45
  def delete(key)
46
- record = Store.find_by_key key_for(key)
46
+ record = Store.find_by_key_name key_for(key)
47
47
  if record
48
- Store.where(:key => key_for(record.key)).delete_all
48
+ Store.where(:key_name => key_for(record.key_name)).delete_all
49
49
  deserialize record.value
50
50
  end
51
51
  end
52
52
 
53
53
  def store(key, value, options = {})
54
- record = Store.new :key => key_for(key), :value => serialize(value)
54
+ record = Store.find_by_key_name key_for(key)
55
+ record ||= Store.new :key_name => key_for(key)
56
+ record.value = serialize(value)
55
57
  record.save!
56
58
  value
57
59
  end
@@ -1,3 +1,3 @@
1
1
  module Moneta
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
  end
@@ -19,6 +19,13 @@ if defined?(ActiveRecord)
19
19
  end
20
20
 
21
21
  it_should_behave_like "a read/write Moneta cache"
22
+
23
+ it 'updates an existing key/value' do
24
+ @cache['foo/bar'] = 4
25
+ @cache['foo/bar'] += 4
26
+ records = Moneta::Adapters::ActiveRecord::Store.find :all, :conditions => { :key_name => 'foo/bar' }
27
+ records.count.should == 1
28
+ end
22
29
  end
23
30
 
24
31
  context 'using preexisting ActiveRecord connection' do
metadata CHANGED
@@ -1,74 +1,61 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: dkastner-moneta
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 0
8
- - 3
9
- version: 1.0.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.4
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Yehuda Katz
13
9
  - Derek Kastner
14
10
  autorequire:
15
11
  bindir: bin
16
12
  cert_chain: []
17
-
18
- date: 2011-02-10 00:00:00 -05:00
13
+ date: 2011-02-10 00:00:00.000000000 -05:00
19
14
  default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
22
17
  name: bundler
23
- requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirement: &2156656780 !ruby/object:Gem::Requirement
24
19
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- version: "0"
20
+ requirements:
21
+ - - ! '>='
22
+ - !ruby/object:Gem::Version
23
+ version: '0'
31
24
  type: :development
32
25
  prerelease: false
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
26
+ version_requirements: *2156656780
27
+ - !ruby/object:Gem::Dependency
35
28
  name: rake
36
- requirement: &id002 !ruby/object:Gem::Requirement
29
+ requirement: &2156656300 !ruby/object:Gem::Requirement
37
30
  none: false
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 0
43
- version: "0"
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
44
35
  type: :development
45
36
  prerelease: false
46
- version_requirements: *id002
47
- - !ruby/object:Gem::Dependency
37
+ version_requirements: *2156656300
38
+ - !ruby/object:Gem::Dependency
48
39
  name: rspec
49
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ requirement: &2156655840 !ruby/object:Gem::Requirement
50
41
  none: false
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- segments:
55
- - 0
56
- version: "0"
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
57
46
  type: :development
58
47
  prerelease: false
59
- version_requirements: *id003
48
+ version_requirements: *2156655840
60
49
  description: A unified interface to key/value stores
61
- email:
50
+ email:
62
51
  - wycats@gmail.com
63
52
  - dkastner@gmail.com
64
53
  executables: []
65
-
66
54
  extensions: []
67
-
68
- extra_rdoc_files:
55
+ extra_rdoc_files:
69
56
  - README
70
57
  - LICENSE
71
- files:
58
+ files:
72
59
  - .gitignore
73
60
  - Gemfile
74
61
  - LICENSE
@@ -125,38 +112,30 @@ files:
125
112
  has_rdoc: true
126
113
  homepage: http://github.com/dkastner/moneta
127
114
  licenses: []
128
-
129
115
  post_install_message:
130
116
  rdoc_options: []
131
-
132
- require_paths:
117
+ require_paths:
133
118
  - lib
134
- required_ruby_version: !ruby/object:Gem::Requirement
119
+ required_ruby_version: !ruby/object:Gem::Requirement
135
120
  none: false
136
- requirements:
137
- - - ">="
138
- - !ruby/object:Gem::Version
139
- hash: -2374182191291410286
140
- segments:
141
- - 0
142
- version: "0"
143
- required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
126
  none: false
145
- requirements:
146
- - - ">="
147
- - !ruby/object:Gem::Version
148
- hash: -2374182191291410286
149
- segments:
150
- - 0
151
- version: "0"
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
152
131
  requirements: []
153
-
154
132
  rubyforge_project:
155
- rubygems_version: 1.3.7
133
+ rubygems_version: 1.6.2
156
134
  signing_key:
157
135
  specification_version: 3
158
- summary: A unified interface to key/value stores, including MongoDB, Redis, Tokyo, and ActiveRecord
159
- test_files:
136
+ summary: A unified interface to key/value stores, including MongoDB, Redis, Tokyo,
137
+ and ActiveRecord
138
+ test_files:
160
139
  - spec/moneta_active_record_spec.rb
161
140
  - spec/moneta_basic_file_spec.rb
162
141
  - spec/moneta_couch_spec.rb