persistent-cache 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c8b77545d0f4b605d15137012b0fcaf1f849032
4
- data.tar.gz: e2258f5db2125f20ca38253e8f6fd51065783aca
3
+ metadata.gz: 68dd568fb3b97d162664532ee06caf46f2a0f065
4
+ data.tar.gz: 7fbfeda53e86fc9fa842720b70e12dd141071d47
5
5
  SHA512:
6
- metadata.gz: 6282dbd4b4916eedf1a97dbdb0d6f0a2c28422a7f6f0191c29e112b6a0b76e5daa42d22b2a0e8994b7eebce4333e877ec79fc8d8e927f9d9edd6985302ada000
7
- data.tar.gz: 03eaed66ba58ca33230093b2b892be3f9bf889e354f610ebdd9e5a823f9fd816d1cb111c151e275101b45ba5dd680114100aed28f46a3e7350395f9ed581442a
6
+ metadata.gz: 94eb9ead4f1199fea92d7d6adf6097f55ad6b6f5672aaf7c94600cd4a0c63d892999de42c8443b0591c7d5a6fe67ee0f715be1ff603250e1e6fb335e1592b6b8
7
+ data.tar.gz: 0714b953628f1c326d59ac070f85f9a56dd08fc65fe32228fd28ead66d022dca2eb84cf41f30b6cf58f4907ecea99fb0ad863a9f69bcb630e93b6a22af671711
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Wynand van Dyk, Ernst van Graan, Hetzner (Pty) Ltd
1
+ Copyright (c) 2012 Ernst van Graan
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -113,9 +113,7 @@ If you'd like persistent cache to rather store keys using an encoding of your pr
113
113
 
114
114
  Please send feedback and comments to the authors at:
115
115
 
116
- Ernst van Graan <ernst.van.graan@hetzner.co.za>
117
-
118
- Wynand van Dyk <wynand.van.dyk@hetzner.co.za>
116
+ Ernst van Graan <ernst.van.graan@gmail.com>
119
117
 
120
118
  1. Fork it
121
119
  2. Create your feature branch (`git checkout -b my-new-feature`)
@@ -1,3 +1,3 @@
1
1
  module Persistent
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -4,11 +4,11 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'persistent-cache/version'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
- gem.authors = ["Ernst van Graan", "Wynand van Dyk"]
8
- gem.email = ["ernst.van.graan@hetzner.co.za", "wvd@hetzner.co.za"]
7
+ gem.authors = ["Ernst van Graan"]
8
+ gem.email = ["ernst.van.graan@gmail.com"]
9
9
  gem.description = %q{Persistent Cache using a pluggable back-end (e.g. SQLite)}
10
10
  gem.summary = %q{Persistent Cache has a default freshness threshold of 179 days after which entries are no longer returned}
11
- gem.homepage = ""
11
+ gem.homepage = "https://github.com/evangraan/persistent-cache.git"
12
12
 
13
13
  gem.files = `git ls-files`.split($\)
14
14
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -67,55 +67,90 @@ describe Persistent::StorageSQLite do
67
67
 
68
68
  context "when asked to store a key value pair" do
69
69
  it "should store the key/value pair in the db, with the current time as timestamp" do
70
- start_time = Time.now - 1
71
- @iut.save_key_value_pair(@test_key, @test_value)
72
- handle = SQLite3::Database.open(@db_name)
73
- result = handle.execute "select value, timestamp from #{Persistent::StorageSQLite::DB_TABLE} where key=?", serialize(@test_key)
74
- expect(result.nil?).to eq(false)
75
- expect(result[0].nil?).to eq(false)
76
- expect(result[0][0]).to eq(serialize(@test_value))
77
- test_time = Time.parse(result[0][1])
78
- expect(test_time).to be > start_time
79
- expect(test_time).to be < start_time + 600
70
+ attempts = 0
71
+ begin
72
+ start_time = Time.now - 1
73
+ @iut.save_key_value_pair(@test_key, @test_value)
74
+ handle = SQLite3::Database.open(@db_name)
75
+ result = handle.execute "select value, timestamp from #{Persistent::StorageSQLite::DB_TABLE} where key=?", serialize(@test_key)
76
+ expect(result.nil?).to eq(false)
77
+ expect(result[0].nil?).to eq(false)
78
+ expect(result[0][0]).to eq(serialize(@test_value))
79
+ test_time = Time.parse(result[0][1])
80
+ expect(test_time).to be > start_time
81
+ expect(test_time).to be < start_time + 600
82
+ rescue SQLite3::IOException
83
+ attempts = attempts + 1
84
+ raise if attempts > 3
85
+ retry
86
+ end
80
87
  end
81
88
 
82
89
  it "should store the key/value pair in the db, with a timestamp specified" do
83
- test_time = (Time.now - 2500)
84
- @iut.save_key_value_pair(@test_key, @test_value, test_time)
85
- handle = SQLite3::Database.open(@db_name)
86
- result = handle.execute "select value, timestamp from #{Persistent::StorageSQLite::DB_TABLE} where key=?", serialize(@test_key)
87
- expect(result.nil?).to eq(false)
88
- expect(result[0].nil?).to eq(false)
89
- expect(result[0][0]).to eq(serialize(@test_value))
90
- time_retrieved = Time.parse(result[0][1])
91
- expect(time_retrieved.to_s).to eq(test_time.to_s)
90
+ attempte = 0
91
+ begin
92
+ test_time = (Time.now - 2500)
93
+ @iut.save_key_value_pair(@test_key, @test_value, test_time)
94
+ handle = SQLite3::Database.open(@db_name)
95
+ result = handle.execute "select value, timestamp from #{Persistent::StorageSQLite::DB_TABLE} where key=?", serialize(@test_key)
96
+ expect(result.nil?).to eq(false)
97
+ expect(result[0].nil?).to eq(false)
98
+ expect(result[0][0]).to eq(serialize(@test_value))
99
+ time_retrieved = Time.parse(result[0][1])
100
+ expect(time_retrieved.to_s).to eq(test_time.to_s)
101
+ rescue SQLite3::IOException
102
+ attempts = attempts + 1
103
+ raise if attempts > 3
104
+ retry
105
+ end
92
106
  end
93
107
 
94
108
  it "should overwrite the existing key/value pair if they already exist" do
95
- @iut.save_key_value_pair(@test_key, @test_value)
96
- @iut.save_key_value_pair(@test_key, "testvalue2")
97
- handle = SQLite3::Database.open(@db_name)
98
- result = handle.execute "select value from #{Persistent::StorageSQLite::DB_TABLE} where key=?", serialize(@test_key)
99
- expect(result.nil?).to eq(false)
100
- expect(result[0].nil?).to eq(false)
101
- expect(result.size).to eq(1)
102
- expect(result[0][0]).to eq(serialize("testvalue2"))
109
+ attempts = 0
110
+ begin
111
+ @iut.save_key_value_pair(@test_key, @test_value)
112
+ @iut.save_key_value_pair(@test_key, "testvalue2")
113
+ handle = SQLite3::Database.open(@db_name)
114
+ result = handle.execute "select value from #{Persistent::StorageSQLite::DB_TABLE} where key=?", serialize(@test_key)
115
+ expect(result.nil?).to eq(false)
116
+ expect(result[0].nil?).to eq(false)
117
+ expect(result.size).to eq(1)
118
+ expect(result[0][0]).to eq(serialize("testvalue2"))
119
+ rescue SQLite3::IOException
120
+ attempts = attempts + 1
121
+ raise if attempts > 3
122
+ retry
123
+ end
103
124
  end
104
125
  end
105
126
 
106
127
  context "When looking up a value given its key" do
107
128
  it "should retrieve the value from the database" do
108
- @iut.save_key_value_pair(@test_key, @test_value)
109
- result = @iut.lookup_key(@test_key)
110
- expect(result[0]).to eq(@test_value)
129
+ attempts = 0
130
+ begin
131
+ @iut.save_key_value_pair(@test_key, @test_value)
132
+ result = @iut.lookup_key(@test_key)
133
+ expect(result[0]).to eq(@test_value)
134
+ rescue SQLite3::IOException
135
+ attempts = attempts + 1
136
+ raise if attempts > 3
137
+ retry
138
+ end
111
139
  end
112
140
 
113
141
  it "should retrieve the timestamp when the value was stored from the database" do
114
- now = Time.now.to_s
115
- @iut.save_key_value_pair(@test_key, @test_value)
116
- sleep 1
117
- result = @iut.lookup_key(@test_key)
118
- expect(result[1]).to eq(now)
142
+ attempts = 0
143
+ begin
144
+ now = Time.now.to_s
145
+ @iut.save_key_value_pair(@test_key, @test_value)
146
+ sleep 1
147
+ result = @iut.lookup_key(@test_key)
148
+ expect(result[1]).to eq(now)
149
+ rescue SQLite3::IOException
150
+ attempts = attempts + 1
151
+ raise if attempts > 3
152
+ retry
153
+ end
119
154
  end
120
155
 
121
156
  it "should return an empty array if a key is not in the database" do
@@ -131,12 +166,19 @@ describe Persistent::StorageSQLite do
131
166
  end
132
167
 
133
168
  it "should delete the entry if it is present" do
134
- @iut.save_key_value_pair(@test_key, @test_value)
135
- result = @iut.lookup_key(@test_key)
136
- expect(result[0]).to eq(@test_value)
137
- @iut.delete_entry(@test_key)
138
- result = @iut.lookup_key(@test_key)
139
- expect(result).to eq(nil)
169
+ attempts = 0
170
+ begin
171
+ @iut.save_key_value_pair(@test_key, @test_value)
172
+ result = @iut.lookup_key(@test_key)
173
+ expect(result[0]).to eq(@test_value)
174
+ @iut.delete_entry(@test_key)
175
+ result = @iut.lookup_key(@test_key)
176
+ expect(result).to eq(nil)
177
+ rescue SQLite3::IOException
178
+ attempts = attempts + 1
179
+ raise if attempts > 3
180
+ retry
181
+ end
140
182
  end
141
183
  end
142
184
 
@@ -192,6 +234,8 @@ describe Persistent::StorageSQLite do
192
234
  iut.save_key_value_pair("one", "one")
193
235
  iut.save_key_value_pair("two", "two")
194
236
  iut.save_key_value_pair("three", "three")
237
+ rescue SQLite3::IOException
238
+ retry
195
239
  end
196
240
 
197
241
  def delete_database
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: persistent-cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernst van Graan
8
- - Wynand van Dyk
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2016-04-12 00:00:00.000000000 Z
11
+ date: 2016-07-24 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
@@ -139,8 +138,7 @@ dependencies:
139
138
  version: '0'
140
139
  description: Persistent Cache using a pluggable back-end (e.g. SQLite)
141
140
  email:
142
- - ernst.van.graan@hetzner.co.za
143
- - wvd@hetzner.co.za
141
+ - ernst.van.graan@gmail.com
144
142
  executables: []
145
143
  extensions: []
146
144
  extra_rdoc_files: []
@@ -161,7 +159,7 @@ files:
161
159
  - spec/storage/storage_directory_spec.rb
162
160
  - spec/storage/storage_ram_spec.rb
163
161
  - spec/storage/storage_sqlite_spec.rb
164
- homepage: ''
162
+ homepage: https://github.com/evangraan/persistent-cache.git
165
163
  licenses: []
166
164
  metadata: {}
167
165
  post_install_message: