millas 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -5
- data/lib/millas.rb +17 -1
- data/lib/millas/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f874c313e3dba20c1edb48302ba1de6e66ca4b61
|
4
|
+
data.tar.gz: 3c7c56800470abdf5e497aea18c14fb2f83d280a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc73a92294b9f7f3e5d4a8e67add7e7eec31cf6d089b1ed612819d8086dbf546b202e8eb0cfad7bded8102e87dbdc788876f15036356a0aff16aaff3f90c495d
|
7
|
+
data.tar.gz: 80daab5b5819e4dcf24ea8a3e63a09e10fc3f1d43b915c92b9f34f8cf575f493b149d107345c92e2c80f0ec29d79550cb831039d2be944b371f7d20c7bd3dd75
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ Millas is a simple cache mechanism. In this mechanism, cached values are dispers
|
|
4
4
|
|
5
5
|
By the way, Millas is a magic cake which becomes 3 layers when baked once. And it is traditional sweets in Landes (France).
|
6
6
|
|
7
|
-
|
7
|
+
<img src="https://user-images.githubusercontent.com/4189626/27506204-9d02d5f0-58ee-11e7-8517-8b16a003fd42.png" width="200px">
|
8
8
|
|
9
9
|
## Mechanism
|
10
10
|
|
@@ -12,13 +12,13 @@ By the way, Millas is a magic cake which becomes 3 layers when baked once. And i
|
|
12
12
|
|
13
13
|
Cached values whose key is appended random and specified number to the end.
|
14
14
|
|
15
|
-
|
15
|
+
<img src="https://user-images.githubusercontent.com/4189626/27507452-b372eebc-590a-11e7-88fc-32cc424454b7.jpg" width="500px">
|
16
16
|
|
17
17
|
### Layered in time
|
18
18
|
|
19
19
|
Expiration time of cached values is Layered.
|
20
20
|
|
21
|
-
|
21
|
+
<img src="https://user-images.githubusercontent.com/4189626/27507451-b2760260-590a-11e7-90a9-d481cb4e8bc2.png" width="500px">
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
@@ -52,13 +52,11 @@ cache.delete('millas')
|
|
52
52
|
Add this line to your application's Gemfile:
|
53
53
|
|
54
54
|
```ruby
|
55
|
-
gem 'dalli'
|
56
55
|
gem 'millas'
|
57
56
|
```
|
58
57
|
|
59
58
|
Or install it yourself as:
|
60
59
|
```bash
|
61
|
-
$ gem install dalli
|
62
60
|
$ gem install millas
|
63
61
|
```
|
64
62
|
|
data/lib/millas.rb
CHANGED
@@ -90,10 +90,26 @@ class ActiveSupport::Cache::DalliStore
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def decorated_name(name, num = nil)
|
93
|
-
"#{name}-#{num ||
|
93
|
+
"#{name}-#{num || magic_number}"
|
94
94
|
end
|
95
95
|
|
96
96
|
def advanced_expires_in(expires_in, n)
|
97
97
|
expires_in + second_intervals*(n-1)
|
98
98
|
end
|
99
|
+
|
100
|
+
def magic_number
|
101
|
+
number = dispersion_number
|
102
|
+
# quadratic function
|
103
|
+
result = number**rand
|
104
|
+
# feel good factor (max = 0.35)
|
105
|
+
alpha = number/40.to_f
|
106
|
+
max_alpha = 0.35
|
107
|
+
result += if alpha < max_alpha
|
108
|
+
alpha
|
109
|
+
else
|
110
|
+
max_alpha
|
111
|
+
end
|
112
|
+
# return opposite number of the maximum value
|
113
|
+
number - result.floor + 1
|
114
|
+
end
|
99
115
|
end
|
data/lib/millas/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: millas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takuya Okuhara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
100
|
rubyforge_project:
|
101
|
-
rubygems_version: 2.
|
101
|
+
rubygems_version: 2.6.13
|
102
102
|
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: Simple and dispersed cache mechanism.
|