dkastner-moneta 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/lib/moneta/adapters/active_record.rb +7 -7
- data/lib/moneta/version.rb +1 -1
- data/spec/moneta_active_record_spec.rb +1 -1
- metadata +9 -11
data/Gemfile
CHANGED
@@ -26,33 +26,33 @@ module Moneta
|
|
26
26
|
def migrate
|
27
27
|
unless Store.table_exists?
|
28
28
|
Store.connection.create_table Store.table_name do |t|
|
29
|
-
t.string '
|
29
|
+
t.string 'key', :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.
|
36
|
+
record = Store.find_by_key key_for(key)
|
37
37
|
!record.nil?
|
38
38
|
end
|
39
39
|
|
40
40
|
def [](key)
|
41
|
-
record = Store.
|
41
|
+
record = Store.find_by_key key_for(key)
|
42
42
|
record ? deserialize(record.value) : nil
|
43
43
|
end
|
44
44
|
|
45
45
|
def delete(key)
|
46
|
-
record = Store.
|
46
|
+
record = Store.find_by_key key_for(key)
|
47
47
|
if record
|
48
|
-
Store.where(:
|
48
|
+
Store.where(:key => key_for(record.key)).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.
|
55
|
-
record ||= Store.new :
|
54
|
+
record = Store.find_by_key key_for(key)
|
55
|
+
record ||= Store.new :key => key_for(key)
|
56
56
|
record.value = serialize(value)
|
57
57
|
record.save!
|
58
58
|
value
|
data/lib/moneta/version.rb
CHANGED
@@ -23,7 +23,7 @@ if defined?(ActiveRecord)
|
|
23
23
|
it 'updates an existing key/value' do
|
24
24
|
@cache['foo/bar'] = 4
|
25
25
|
@cache['foo/bar'] += 4
|
26
|
-
records = Moneta::Adapters::ActiveRecord::Store.find :all, :conditions => { :
|
26
|
+
records = Moneta::Adapters::ActiveRecord::Store.find :all, :conditions => { :key => 'foo/bar' }
|
27
27
|
records.count.should == 1
|
28
28
|
end
|
29
29
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dkastner-moneta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,12 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-02-10 00:00:00.
|
14
|
-
default_executable:
|
13
|
+
date: 2011-02-10 00:00:00.000000000Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: bundler
|
18
|
-
requirement: &
|
17
|
+
requirement: &2152743980 !ruby/object:Gem::Requirement
|
19
18
|
none: false
|
20
19
|
requirements:
|
21
20
|
- - ! '>='
|
@@ -23,10 +22,10 @@ dependencies:
|
|
23
22
|
version: '0'
|
24
23
|
type: :development
|
25
24
|
prerelease: false
|
26
|
-
version_requirements: *
|
25
|
+
version_requirements: *2152743980
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: rake
|
29
|
-
requirement: &
|
28
|
+
requirement: &2152743560 !ruby/object:Gem::Requirement
|
30
29
|
none: false
|
31
30
|
requirements:
|
32
31
|
- - ! '>='
|
@@ -34,10 +33,10 @@ dependencies:
|
|
34
33
|
version: '0'
|
35
34
|
type: :development
|
36
35
|
prerelease: false
|
37
|
-
version_requirements: *
|
36
|
+
version_requirements: *2152743560
|
38
37
|
- !ruby/object:Gem::Dependency
|
39
38
|
name: rspec
|
40
|
-
requirement: &
|
39
|
+
requirement: &2152743140 !ruby/object:Gem::Requirement
|
41
40
|
none: false
|
42
41
|
requirements:
|
43
42
|
- - ! '>='
|
@@ -45,7 +44,7 @@ dependencies:
|
|
45
44
|
version: '0'
|
46
45
|
type: :development
|
47
46
|
prerelease: false
|
48
|
-
version_requirements: *
|
47
|
+
version_requirements: *2152743140
|
49
48
|
description: A unified interface to key/value stores
|
50
49
|
email:
|
51
50
|
- wycats@gmail.com
|
@@ -109,7 +108,6 @@ files:
|
|
109
108
|
- spec/moneta_yaml_spec.rb
|
110
109
|
- spec/shared.rb
|
111
110
|
- spec/spec_helper.rb
|
112
|
-
has_rdoc: true
|
113
111
|
homepage: http://github.com/dkastner/moneta
|
114
112
|
licenses: []
|
115
113
|
post_install_message:
|
@@ -130,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
128
|
version: '0'
|
131
129
|
requirements: []
|
132
130
|
rubyforge_project:
|
133
|
-
rubygems_version: 1.
|
131
|
+
rubygems_version: 1.8.5
|
134
132
|
signing_key:
|
135
133
|
specification_version: 3
|
136
134
|
summary: A unified interface to key/value stores, including MongoDB, Redis, Tokyo,
|