disk_store 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +11 -0
- data/lib/disk_store.rb +6 -1
- data/lib/disk_store/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1f61e81fe74be2161fb98233d6a41a52cf4057c
|
4
|
+
data.tar.gz: e03209fedb0146990f8ad71ea2493d1c90539250
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 558bff6fcf45167bb343cdf9c7bb2ae18c7bc6f4432323b581237a5afbdaa203ee45aa5c31c83c8c439d100d16e9197e0106e651b6148a0354b6ea2fc196db6d
|
7
|
+
data.tar.gz: e66e4ffcc8af5bafebf9c482f6d22ce76e1b7f574e3a79c83b6acb693f5b18917652c5346f0063b2535e26d3eb76dde5821b559184d67991697ccc745e6e1029
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -59,6 +59,9 @@ cache = DiskStore.new('cache/dir', eviction_strategy: :LRU)
|
|
59
59
|
```ruby
|
60
60
|
cache = DiskStore.new
|
61
61
|
cached_file = cache.read("my_cache_key") #=> File.open('somewhere_on_disk')
|
62
|
+
|
63
|
+
# With MD5 validation
|
64
|
+
cached_file = cache.read("my_cache_key", expected_md5)
|
62
65
|
```
|
63
66
|
|
64
67
|
### Writing
|
@@ -66,6 +69,9 @@ cached_file = cache.read("my_cache_key") #=> File.open('somewhere_on_disk')
|
|
66
69
|
```ruby
|
67
70
|
cache = DiskStore.new
|
68
71
|
cache.write("my_cache_key", File.open('file.psd', 'rb'))
|
72
|
+
|
73
|
+
# With MD5 validation
|
74
|
+
cache.write("my_cache_key", File.open("file.psd", 'rb'), expected_md5)
|
69
75
|
```
|
70
76
|
|
71
77
|
### Fetching
|
@@ -75,6 +81,11 @@ cache = DiskStore.new
|
|
75
81
|
cache.fetch("my_cache_key") do
|
76
82
|
File.open('file.psd', 'rb')
|
77
83
|
end
|
84
|
+
|
85
|
+
# With MD5 validation
|
86
|
+
cache.fetch("my_cache_key", expected_md5) do
|
87
|
+
File.open('file.psd', 'rb')
|
88
|
+
end
|
78
89
|
```
|
79
90
|
|
80
91
|
This is where it gets cool. You can also feed it other IO classes.
|
data/lib/disk_store.rb
CHANGED
@@ -56,7 +56,12 @@ class DiskStore
|
|
56
56
|
def delete(key)
|
57
57
|
file_path = key_file_path(key)
|
58
58
|
if exist?(key)
|
59
|
-
|
59
|
+
begin
|
60
|
+
File.delete(file_path)
|
61
|
+
rescue Error::ENOENT
|
62
|
+
# Weirdness can happen with concurrency
|
63
|
+
end
|
64
|
+
|
60
65
|
delete_empty_directories(File.dirname(file_path))
|
61
66
|
end
|
62
67
|
true
|
data/lib/disk_store/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: disk_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelly Sutton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|