sequel-cacheable 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +46 -1
- data/VERSION +1 -1
- data/lib/sequel-cacheable.rb +7 -1
- data/sequel-cacheable.gemspec +1 -1
- data/spec/lib/sequel-cacheable_spec.rb +9 -4
- data/spec/spec_helper.rb +9 -4
- metadata +34 -34
data/README.rdoc
CHANGED
@@ -1,6 +1,51 @@
|
|
1
1
|
= sequel-cacheable
|
2
2
|
|
3
|
-
|
3
|
+
This plug-in caching mechanism to implement the Model of the Sequel
|
4
|
+
|
5
|
+
== Usage
|
6
|
+
|
7
|
+
Gemfile write:
|
8
|
+
|
9
|
+
gem "sequel"
|
10
|
+
gem "sequel-cacheable"
|
11
|
+
gem "redis"
|
12
|
+
|
13
|
+
Source code write:
|
14
|
+
|
15
|
+
Sequel::Model.plugin :cacheable, Redis.new(host: 'localhost', port: 6379)
|
16
|
+
|
17
|
+
Caching!
|
18
|
+
|
19
|
+
== Options
|
20
|
+
|
21
|
+
Sequel::Model.plugin :cacheable, cache_client, options_hash
|
22
|
+
|
23
|
+
tested cache_client:
|
24
|
+
|
25
|
+
* Redis[https://rubygems.org/gems/redis]
|
26
|
+
* Memcached[https://rubygems.org/gems/memcache]
|
27
|
+
|
28
|
+
options:
|
29
|
+
|
30
|
+
{
|
31
|
+
:ttl => 3600, # time to live. default 3600
|
32
|
+
:ignore_exception => false, # through exception. default false
|
33
|
+
:pack_lib => MessagePack, # cache packing library. This Object should be have pack / unpack method.
|
34
|
+
:query_cache => false # enable query cache. default true if cache client implemented keys method
|
35
|
+
}
|
36
|
+
|
37
|
+
== Cache Timing
|
38
|
+
|
39
|
+
* select
|
40
|
+
* Model.find(id) => Model Cache
|
41
|
+
* Model.where(cond).all => Query Cache
|
42
|
+
* insert / update
|
43
|
+
* clear model cache
|
44
|
+
* clear all query caches of model
|
45
|
+
* store a new record model cache
|
46
|
+
* delete / destroy
|
47
|
+
* clear model cache
|
48
|
+
* clear all query caches of model
|
4
49
|
|
5
50
|
== Contributing to sequel-cacheable
|
6
51
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/lib/sequel-cacheable.rb
CHANGED
@@ -111,8 +111,12 @@ module Sequel::Plugins
|
|
111
111
|
value = object.delete(key)
|
112
112
|
key = key.to_sym rescue key
|
113
113
|
case db_schema[key][:type]
|
114
|
+
when :date
|
115
|
+
value = Date.new(*value)
|
114
116
|
when :time
|
115
117
|
value = Sequel::SQLTime.at(value[0], value[1])
|
118
|
+
when :datetime
|
119
|
+
value = Time.at(value[0], value[1])
|
116
120
|
end
|
117
121
|
object[key] = value
|
118
122
|
end
|
@@ -138,7 +142,9 @@ module Sequel::Plugins
|
|
138
142
|
hash = {}
|
139
143
|
@values.each_pair do | key, value |
|
140
144
|
case value
|
141
|
-
when
|
145
|
+
when Date
|
146
|
+
value = [value.year, value.mon, value.mday, value.start]
|
147
|
+
when Sequel::SQLTime, Time
|
142
148
|
value = [value.to_i, value.usec]
|
143
149
|
end
|
144
150
|
hash[key] = value
|
data/sequel-cacheable.gemspec
CHANGED
@@ -22,13 +22,18 @@ QueenCheck::Arbitrary(String, QueenCheck::Gen.quadratic(200).bind { | length |
|
|
22
22
|
|
23
23
|
describe Sequel::Plugins::Cacheable do
|
24
24
|
QueenCheck("Generate Test Datas",
|
25
|
-
String, Fixnum, Float) do |string, fixnum, float|
|
25
|
+
String, Fixnum, Float, Bignum, Boolean) do |string, fixnum, float, bignum, boolean|
|
26
26
|
float = float * 1.0 / (10 ** (rand(4) + 1))
|
27
27
|
RedisModel.create({
|
28
28
|
:string => string,
|
29
|
-
:
|
29
|
+
:integer => fixnum,
|
30
30
|
:float => float,
|
31
|
-
:
|
31
|
+
:bignum => bignum,
|
32
|
+
:numeric => BigDecimal(float.to_s),
|
33
|
+
:date => Date.today,
|
34
|
+
:datetime => DateTime.now,
|
35
|
+
:time => Time.now,
|
36
|
+
:bool => boolean
|
32
37
|
})
|
33
38
|
true
|
34
39
|
end
|
@@ -127,7 +132,7 @@ describe Sequel::Plugins::Cacheable do
|
|
127
132
|
proc{ RedisModel.plugin :something_or_other}.should raise_error(LoadError)
|
128
133
|
end
|
129
134
|
|
130
|
-
its("columns") { should == [:id
|
135
|
+
its("columns") { should == [:id,:string,:integer,:float,:bignum,:numeric,:date,:datetime,:time,:bool] }
|
131
136
|
|
132
137
|
its("plugins") {
|
133
138
|
should_not include(Sequel::Plugins::Cacheable)
|
data/spec/spec_helper.rb
CHANGED
@@ -18,10 +18,15 @@ RSpec.configure do |config|
|
|
18
18
|
DB = Sequel.sqlite
|
19
19
|
DB.create_table(:spec) do
|
20
20
|
primary_key :id, :auto_increment => true
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
String :string
|
22
|
+
Integer :integer
|
23
|
+
Float :float
|
24
|
+
Bignum :bignum
|
25
|
+
BigDecimal :numeric
|
26
|
+
Date :date
|
27
|
+
DateTime :datetime
|
28
|
+
Time :time, :only_time=>true
|
29
|
+
TrueClass :bool
|
25
30
|
end
|
26
31
|
RedisCli = Redis.new(:host => 'localhost', :port => 6379)
|
27
32
|
MemcacheCli = Memcache.new(:server => 'localhost:11211')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel-cacheable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-02-26 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sequel
|
16
|
-
requirement: &
|
16
|
+
requirement: &70191688070940 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.32.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70191688070940
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: msgpack
|
27
|
-
requirement: &
|
27
|
+
requirement: &70191688070240 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.4.6
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70191688070240
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: hashr
|
38
|
-
requirement: &
|
38
|
+
requirement: &70191688069520 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.0.19
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70191688069520
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
|
-
requirement: &
|
49
|
+
requirement: &70191688068520 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.0.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70191688068520
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &70191688067220 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 2.8.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70191688067220
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: yard
|
71
|
-
requirement: &
|
71
|
+
requirement: &70191688082660 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0.7'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70191688082660
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rdoc
|
82
|
-
requirement: &
|
82
|
+
requirement: &70191688081880 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '3.12'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70191688081880
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: jeweler
|
93
|
-
requirement: &
|
93
|
+
requirement: &70191688081020 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: 1.8.3
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70191688081020
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: simplecov
|
104
|
-
requirement: &
|
104
|
+
requirement: &70191688080260 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: 0.6.1
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70191688080260
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: guard
|
115
|
-
requirement: &
|
115
|
+
requirement: &70191688079520 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ~>
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: 1.0.0
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *70191688079520
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: guard-rspec
|
126
|
-
requirement: &
|
126
|
+
requirement: &70191688078900 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - ~>
|
@@ -131,10 +131,10 @@ dependencies:
|
|
131
131
|
version: 0.6.0
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *70191688078900
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: growl
|
137
|
-
requirement: &
|
137
|
+
requirement: &70191688078340 !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|
140
140
|
- - ! '>='
|
@@ -142,10 +142,10 @@ dependencies:
|
|
142
142
|
version: '0'
|
143
143
|
type: :development
|
144
144
|
prerelease: false
|
145
|
-
version_requirements: *
|
145
|
+
version_requirements: *70191688078340
|
146
146
|
- !ruby/object:Gem::Dependency
|
147
147
|
name: sqlite3
|
148
|
-
requirement: &
|
148
|
+
requirement: &70191688077480 !ruby/object:Gem::Requirement
|
149
149
|
none: false
|
150
150
|
requirements:
|
151
151
|
- - ! '>='
|
@@ -153,10 +153,10 @@ dependencies:
|
|
153
153
|
version: '0'
|
154
154
|
type: :development
|
155
155
|
prerelease: false
|
156
|
-
version_requirements: *
|
156
|
+
version_requirements: *70191688077480
|
157
157
|
- !ruby/object:Gem::Dependency
|
158
158
|
name: memcache
|
159
|
-
requirement: &
|
159
|
+
requirement: &70191688076580 !ruby/object:Gem::Requirement
|
160
160
|
none: false
|
161
161
|
requirements:
|
162
162
|
- - ! '>='
|
@@ -164,10 +164,10 @@ dependencies:
|
|
164
164
|
version: '0'
|
165
165
|
type: :development
|
166
166
|
prerelease: false
|
167
|
-
version_requirements: *
|
167
|
+
version_requirements: *70191688076580
|
168
168
|
- !ruby/object:Gem::Dependency
|
169
169
|
name: redis
|
170
|
-
requirement: &
|
170
|
+
requirement: &70191688091020 !ruby/object:Gem::Requirement
|
171
171
|
none: false
|
172
172
|
requirements:
|
173
173
|
- - ! '>='
|
@@ -175,10 +175,10 @@ dependencies:
|
|
175
175
|
version: '0'
|
176
176
|
type: :development
|
177
177
|
prerelease: false
|
178
|
-
version_requirements: *
|
178
|
+
version_requirements: *70191688091020
|
179
179
|
- !ruby/object:Gem::Dependency
|
180
180
|
name: queencheck
|
181
|
-
requirement: &
|
181
|
+
requirement: &70191688090320 !ruby/object:Gem::Requirement
|
182
182
|
none: false
|
183
183
|
requirements:
|
184
184
|
- - ! '>='
|
@@ -186,7 +186,7 @@ dependencies:
|
|
186
186
|
version: '0'
|
187
187
|
type: :development
|
188
188
|
prerelease: false
|
189
|
-
version_requirements: *
|
189
|
+
version_requirements: *70191688090320
|
190
190
|
description: This plug-in caching mechanism to implement the Model of the Sequel
|
191
191
|
email: rosylilly@aduca.org
|
192
192
|
executables: []
|
@@ -223,7 +223,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
223
223
|
version: '0'
|
224
224
|
segments:
|
225
225
|
- 0
|
226
|
-
hash:
|
226
|
+
hash: 2279367899348586694
|
227
227
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
228
|
none: false
|
229
229
|
requirements:
|