millas 0.0.3 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 67be1fa0853b471b58ec3ad08b950c64bf163e8b
4
- data.tar.gz: a981b66ff072908fef0fa845127308180ee6de89
3
+ metadata.gz: f874c313e3dba20c1edb48302ba1de6e66ca4b61
4
+ data.tar.gz: 3c7c56800470abdf5e497aea18c14fb2f83d280a
5
5
  SHA512:
6
- metadata.gz: 028be43e413a3e22606fb5a5e35cdcf23297dd691be8614cacb7640da827ddcbfd3ce631ef6ce11b1be753b223b7e34799fb258950bd7638e2367798bbd6217a
7
- data.tar.gz: e00e5cb431a5ff5dd8debeef66ebaaadc8646ca324727d2f9d35e72af6b61b01584c129e8cb1cd3f74c16d58656d56772da06b3cfc621ab89be1c86656e58ce6
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
- ![compressed_thumbnail_square_small](https://user-images.githubusercontent.com/4189626/27506204-9d02d5f0-58ee-11e7-8517-8b16a003fd42.png)
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
- ![0001](https://user-images.githubusercontent.com/4189626/27507452-b372eebc-590a-11e7-88fc-32cc424454b7.jpg)
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
- ![millas-2-1](https://user-images.githubusercontent.com/4189626/27507451-b2760260-590a-11e7-90a9-d481cb4e8bc2.png)
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
 
@@ -90,10 +90,26 @@ class ActiveSupport::Cache::DalliStore
90
90
  end
91
91
 
92
92
  def decorated_name(name, num = nil)
93
- "#{name}-#{num || dispersions.sample}"
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
@@ -1,3 +1,3 @@
1
1
  module Millas
2
- VERSION = '0.0.3'
2
+ VERSION = '0.1.0'
3
3
  end
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.3
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: 2017-06-24 00:00:00.000000000 Z
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.5.1
101
+ rubygems_version: 2.6.13
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: Simple and dispersed cache mechanism.