lightly 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/lib/lightly/cache_operations.rb +7 -2
- data/lib/lightly/version.rb +1 -1
- metadata +3 -73
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ced5fc7d04bba9051d3e8d07c3a522f47e937d90c2ada27e567fe4f3290e7dc
|
4
|
+
data.tar.gz: 7d02b1c822637ca05b4e1a01c35501c3de1c1505f97a1e9f5561ac8744b146f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 698a691c809a987cc45ed35ef3cbc3ee5be9d7a8a4e088b079ed04f51c0ae6c48e475bd5421534d53bf03bc905c9d76440b44b83678263307e7d084e7b00ab82
|
7
|
+
data.tar.gz: 9b74b4b54267f15ddbfdaf02645f36c1d6f824726f8af827735a2aac1c5780760212dd64286c8a7284e199e93b5fa653b1e06d507a10ade3c81c4d31b3a0b9db
|
data/README.md
CHANGED
@@ -154,6 +154,13 @@ lightly = Lightly.new
|
|
154
154
|
lightly.clear 'example'
|
155
155
|
```
|
156
156
|
|
157
|
+
To clear all expired keys, call:
|
158
|
+
|
159
|
+
```ruby
|
160
|
+
lightly = Lightly.new
|
161
|
+
lightly.prune
|
162
|
+
```
|
163
|
+
|
157
164
|
If your block returns false or nil, the data will not be cached:
|
158
165
|
|
159
166
|
```ruby
|
@@ -50,6 +50,11 @@ class Lightly
|
|
50
50
|
FileUtils.rm_rf dir
|
51
51
|
end
|
52
52
|
|
53
|
+
def prune
|
54
|
+
return false if dir == '/' || dir.empty?
|
55
|
+
Dir["#{dir}/*"].each { |file| expired? file }
|
56
|
+
end
|
57
|
+
|
53
58
|
def cached?(key)
|
54
59
|
path = get_path key
|
55
60
|
File.exist?(path) and File.size(path) > 0 and !expired?(path)
|
@@ -76,14 +81,14 @@ class Lightly
|
|
76
81
|
end
|
77
82
|
end
|
78
83
|
|
79
|
-
|
84
|
+
private
|
80
85
|
|
81
86
|
def load(key)
|
82
87
|
Marshal.load File.binread(get_path key)
|
83
88
|
end
|
84
89
|
|
85
90
|
def expired?(path)
|
86
|
-
expired = life > 0 && File.exist?(path) && Time.
|
91
|
+
expired = life > 0 && File.exist?(path) && Time.now - File.mtime(path) >= life
|
87
92
|
FileUtils.rm path if expired
|
88
93
|
expired
|
89
94
|
end
|
data/lib/lightly/version.rb
CHANGED
metadata
CHANGED
@@ -1,85 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lightly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: runfile
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0.9'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0.9'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: runfile-tasks
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0.4'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0.4'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '3.4'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '3.4'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: simplecov
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.14'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0.14'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: byebug
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '9.0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '9.0'
|
11
|
+
date: 2018-12-23 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
83
13
|
description: Easy to use file cache
|
84
14
|
email: db@dannyben.com
|
85
15
|
executables: []
|