elephas 2.2.0 → 3.0.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.
- data/Gemfile +1 -1
- data/README.md +4 -4
- data/doc/Elephas/{Providers → Backends}/Base.html +48 -38
- data/doc/Elephas/{Providers → Backends}/Hash.html +35 -38
- data/doc/Elephas/{Providers → Backends}/RubyOnRails.html +32 -35
- data/doc/Elephas/{Providers.html → Backends.html} +8 -10
- data/doc/Elephas/Cache.html +894 -111
- data/doc/Elephas/Entry.html +63 -50
- data/doc/Elephas/Version.html +3 -3
- data/doc/Elephas.html +3 -3
- data/doc/_index.html +14 -22
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +5 -5
- data/doc/index.html +5 -5
- data/doc/method_list.html +62 -54
- data/doc/top-level-namespace.html +1 -1
- data/elephas.gemspec +1 -1
- data/lib/elephas/{provider.rb → backends/base.rb} +4 -6
- data/lib/elephas/{providers → backends}/hash.rb +7 -7
- data/lib/elephas/{providers → backends}/ruby_on_rails.rb +4 -6
- data/lib/elephas/cache.rb +47 -29
- data/lib/elephas/entry.rb +6 -6
- data/lib/elephas/version.rb +2 -2
- data/lib/elephas.rb +4 -6
- data/locales/en.yml +1 -1
- data/locales/it.yml +1 -1
- data/spec/elephas/cache_spec.rb +32 -35
- data/spec/elephas/entry_spec.rb +6 -5
- data/spec/elephas/{provider_spec.rb → providers/base_spec.rb} +2 -6
- data/spec/elephas/providers/hash_spec.rb +6 -6
- data/spec/elephas/providers/ruby_on_rails_spec.rb +2 -2
- metadata +14 -14
data/doc/Elephas/Entry.html
CHANGED
@@ -365,7 +365,7 @@
|
|
365
365
|
<li class="public ">
|
366
366
|
<span class="summary_signature">
|
367
367
|
|
368
|
-
<a href="#refresh-instance_method" title="#refresh (instance method)">- (Float) <strong>refresh</strong>(save = false) </a>
|
368
|
+
<a href="#refresh-instance_method" title="#refresh (instance method)">- (Float) <strong>refresh</strong>(save = false, cache = nil) </a>
|
369
369
|
|
370
370
|
|
371
371
|
|
@@ -388,7 +388,7 @@
|
|
388
388
|
<li class="public ">
|
389
389
|
<span class="summary_signature">
|
390
390
|
|
391
|
-
<a href="#valid%3F-instance_method" title="#valid? (instance method)">- (Boolean) <strong>valid?</strong>(
|
391
|
+
<a href="#valid%3F-instance_method" title="#valid? (instance method)">- (Boolean) <strong>valid?</strong>(backend) </a>
|
392
392
|
|
393
393
|
|
394
394
|
|
@@ -695,20 +695,20 @@
|
|
695
695
|
<span class='comment'># Refreshes the entry.
|
696
696
|
</span> <span class='comment'>#
|
697
697
|
</span> <span class='comment'># @param save [Boolean] If to save the refresh value in the cache.
|
698
|
+
</span> <span class='comment'># @param cache [Cache] The cache where to save the entry.
|
698
699
|
</span> <span class='comment'># @return [Float] The new updated_at value.
|
699
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_refresh'>refresh</span><span class='lparen'>(</span><span class='id identifier rubyid_save'>save</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
700
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_refresh'>refresh</span><span class='lparen'>(</span><span class='id identifier rubyid_save'>save</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_cache'>cache</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
700
701
|
<span class='ivar'>@updated_at</span> <span class='op'>=</span> <span class='id identifier rubyid_get_new_updated_at'>get_new_updated_at</span><span class='lparen'>(</span><span class='ivar'>@updated_at</span><span class='rparen'>)</span>
|
701
|
-
<span class='
|
702
|
+
<span class='id identifier rubyid_cache'>cache</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='ivar'>@hash</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_save'>save</span> <span class='op'>&&</span> <span class='id identifier rubyid_cache'>cache</span>
|
702
703
|
<span class='ivar'>@updated_at</span>
|
703
704
|
<span class='kw'>end</span>
|
704
705
|
|
705
706
|
<span class='comment'># Checks if the entry is still valid.
|
706
707
|
</span> <span class='comment'>#
|
707
|
-
</span> <span class='comment'># @param
|
708
|
+
</span> <span class='comment'># @param backend [Backends::Base] The backend to use for the check.
|
708
709
|
</span> <span class='comment'># @return [Boolean] `true` if the entry is still valid, `false` otherwise.
|
709
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_valid?'>valid?</span><span class='lparen'>(</span><span class='id identifier
|
710
|
-
<span class='id identifier
|
711
|
-
<span class='id identifier rubyid_provider'>provider</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span> <span class='op'>-</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_updated_at'>updated_at</span> <span class='op'><</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_ttl'>ttl</span> <span class='op'>/</span> <span class='int'>1000</span>
|
710
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_valid?'>valid?</span><span class='lparen'>(</span><span class='id identifier rubyid_backend'>backend</span><span class='rparen'>)</span>
|
711
|
+
<span class='id identifier rubyid_backend'>backend</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span> <span class='op'>-</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_updated_at'>updated_at</span> <span class='op'><</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_ttl'>ttl</span> <span class='op'>/</span> <span class='int'>1000</span>
|
712
712
|
<span class='kw'>end</span>
|
713
713
|
|
714
714
|
<span class='comment'># Compares to another Entry.
|
@@ -924,20 +924,20 @@
|
|
924
924
|
<span class='comment'># Refreshes the entry.
|
925
925
|
</span> <span class='comment'>#
|
926
926
|
</span> <span class='comment'># @param save [Boolean] If to save the refresh value in the cache.
|
927
|
+
</span> <span class='comment'># @param cache [Cache] The cache where to save the entry.
|
927
928
|
</span> <span class='comment'># @return [Float] The new updated_at value.
|
928
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_refresh'>refresh</span><span class='lparen'>(</span><span class='id identifier rubyid_save'>save</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
929
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_refresh'>refresh</span><span class='lparen'>(</span><span class='id identifier rubyid_save'>save</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_cache'>cache</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
929
930
|
<span class='ivar'>@updated_at</span> <span class='op'>=</span> <span class='id identifier rubyid_get_new_updated_at'>get_new_updated_at</span><span class='lparen'>(</span><span class='ivar'>@updated_at</span><span class='rparen'>)</span>
|
930
|
-
<span class='
|
931
|
+
<span class='id identifier rubyid_cache'>cache</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='ivar'>@hash</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_save'>save</span> <span class='op'>&&</span> <span class='id identifier rubyid_cache'>cache</span>
|
931
932
|
<span class='ivar'>@updated_at</span>
|
932
933
|
<span class='kw'>end</span>
|
933
934
|
|
934
935
|
<span class='comment'># Checks if the entry is still valid.
|
935
936
|
</span> <span class='comment'>#
|
936
|
-
</span> <span class='comment'># @param
|
937
|
+
</span> <span class='comment'># @param backend [Backends::Base] The backend to use for the check.
|
937
938
|
</span> <span class='comment'># @return [Boolean] `true` if the entry is still valid, `false` otherwise.
|
938
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_valid?'>valid?</span><span class='lparen'>(</span><span class='id identifier
|
939
|
-
<span class='id identifier
|
940
|
-
<span class='id identifier rubyid_provider'>provider</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span> <span class='op'>-</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_updated_at'>updated_at</span> <span class='op'><</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_ttl'>ttl</span> <span class='op'>/</span> <span class='int'>1000</span>
|
939
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_valid?'>valid?</span><span class='lparen'>(</span><span class='id identifier rubyid_backend'>backend</span><span class='rparen'>)</span>
|
940
|
+
<span class='id identifier rubyid_backend'>backend</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span> <span class='op'>-</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_updated_at'>updated_at</span> <span class='op'><</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_ttl'>ttl</span> <span class='op'>/</span> <span class='int'>1000</span>
|
941
941
|
<span class='kw'>end</span>
|
942
942
|
|
943
943
|
<span class='comment'># Compares to another Entry.
|
@@ -1153,20 +1153,20 @@
|
|
1153
1153
|
<span class='comment'># Refreshes the entry.
|
1154
1154
|
</span> <span class='comment'>#
|
1155
1155
|
</span> <span class='comment'># @param save [Boolean] If to save the refresh value in the cache.
|
1156
|
+
</span> <span class='comment'># @param cache [Cache] The cache where to save the entry.
|
1156
1157
|
</span> <span class='comment'># @return [Float] The new updated_at value.
|
1157
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_refresh'>refresh</span><span class='lparen'>(</span><span class='id identifier rubyid_save'>save</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
1158
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_refresh'>refresh</span><span class='lparen'>(</span><span class='id identifier rubyid_save'>save</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_cache'>cache</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
1158
1159
|
<span class='ivar'>@updated_at</span> <span class='op'>=</span> <span class='id identifier rubyid_get_new_updated_at'>get_new_updated_at</span><span class='lparen'>(</span><span class='ivar'>@updated_at</span><span class='rparen'>)</span>
|
1159
|
-
<span class='
|
1160
|
+
<span class='id identifier rubyid_cache'>cache</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='ivar'>@hash</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_save'>save</span> <span class='op'>&&</span> <span class='id identifier rubyid_cache'>cache</span>
|
1160
1161
|
<span class='ivar'>@updated_at</span>
|
1161
1162
|
<span class='kw'>end</span>
|
1162
1163
|
|
1163
1164
|
<span class='comment'># Checks if the entry is still valid.
|
1164
1165
|
</span> <span class='comment'>#
|
1165
|
-
</span> <span class='comment'># @param
|
1166
|
+
</span> <span class='comment'># @param backend [Backends::Base] The backend to use for the check.
|
1166
1167
|
</span> <span class='comment'># @return [Boolean] `true` if the entry is still valid, `false` otherwise.
|
1167
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_valid?'>valid?</span><span class='lparen'>(</span><span class='id identifier
|
1168
|
-
<span class='id identifier
|
1169
|
-
<span class='id identifier rubyid_provider'>provider</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span> <span class='op'>-</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_updated_at'>updated_at</span> <span class='op'><</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_ttl'>ttl</span> <span class='op'>/</span> <span class='int'>1000</span>
|
1168
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_valid?'>valid?</span><span class='lparen'>(</span><span class='id identifier rubyid_backend'>backend</span><span class='rparen'>)</span>
|
1169
|
+
<span class='id identifier rubyid_backend'>backend</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span> <span class='op'>-</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_updated_at'>updated_at</span> <span class='op'><</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_ttl'>ttl</span> <span class='op'>/</span> <span class='int'>1000</span>
|
1170
1170
|
<span class='kw'>end</span>
|
1171
1171
|
|
1172
1172
|
<span class='comment'># Compares to another Entry.
|
@@ -1382,20 +1382,20 @@
|
|
1382
1382
|
<span class='comment'># Refreshes the entry.
|
1383
1383
|
</span> <span class='comment'>#
|
1384
1384
|
</span> <span class='comment'># @param save [Boolean] If to save the refresh value in the cache.
|
1385
|
+
</span> <span class='comment'># @param cache [Cache] The cache where to save the entry.
|
1385
1386
|
</span> <span class='comment'># @return [Float] The new updated_at value.
|
1386
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_refresh'>refresh</span><span class='lparen'>(</span><span class='id identifier rubyid_save'>save</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
1387
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_refresh'>refresh</span><span class='lparen'>(</span><span class='id identifier rubyid_save'>save</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_cache'>cache</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
1387
1388
|
<span class='ivar'>@updated_at</span> <span class='op'>=</span> <span class='id identifier rubyid_get_new_updated_at'>get_new_updated_at</span><span class='lparen'>(</span><span class='ivar'>@updated_at</span><span class='rparen'>)</span>
|
1388
|
-
<span class='
|
1389
|
+
<span class='id identifier rubyid_cache'>cache</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='ivar'>@hash</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_save'>save</span> <span class='op'>&&</span> <span class='id identifier rubyid_cache'>cache</span>
|
1389
1390
|
<span class='ivar'>@updated_at</span>
|
1390
1391
|
<span class='kw'>end</span>
|
1391
1392
|
|
1392
1393
|
<span class='comment'># Checks if the entry is still valid.
|
1393
1394
|
</span> <span class='comment'>#
|
1394
|
-
</span> <span class='comment'># @param
|
1395
|
+
</span> <span class='comment'># @param backend [Backends::Base] The backend to use for the check.
|
1395
1396
|
</span> <span class='comment'># @return [Boolean] `true` if the entry is still valid, `false` otherwise.
|
1396
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_valid?'>valid?</span><span class='lparen'>(</span><span class='id identifier
|
1397
|
-
<span class='id identifier
|
1398
|
-
<span class='id identifier rubyid_provider'>provider</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span> <span class='op'>-</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_updated_at'>updated_at</span> <span class='op'><</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_ttl'>ttl</span> <span class='op'>/</span> <span class='int'>1000</span>
|
1397
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_valid?'>valid?</span><span class='lparen'>(</span><span class='id identifier rubyid_backend'>backend</span><span class='rparen'>)</span>
|
1398
|
+
<span class='id identifier rubyid_backend'>backend</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span> <span class='op'>-</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_updated_at'>updated_at</span> <span class='op'><</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_ttl'>ttl</span> <span class='op'>/</span> <span class='int'>1000</span>
|
1399
1399
|
<span class='kw'>end</span>
|
1400
1400
|
|
1401
1401
|
<span class='comment'># Compares to another Entry.
|
@@ -1611,20 +1611,20 @@
|
|
1611
1611
|
<span class='comment'># Refreshes the entry.
|
1612
1612
|
</span> <span class='comment'>#
|
1613
1613
|
</span> <span class='comment'># @param save [Boolean] If to save the refresh value in the cache.
|
1614
|
+
</span> <span class='comment'># @param cache [Cache] The cache where to save the entry.
|
1614
1615
|
</span> <span class='comment'># @return [Float] The new updated_at value.
|
1615
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_refresh'>refresh</span><span class='lparen'>(</span><span class='id identifier rubyid_save'>save</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
1616
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_refresh'>refresh</span><span class='lparen'>(</span><span class='id identifier rubyid_save'>save</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_cache'>cache</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
1616
1617
|
<span class='ivar'>@updated_at</span> <span class='op'>=</span> <span class='id identifier rubyid_get_new_updated_at'>get_new_updated_at</span><span class='lparen'>(</span><span class='ivar'>@updated_at</span><span class='rparen'>)</span>
|
1617
|
-
<span class='
|
1618
|
+
<span class='id identifier rubyid_cache'>cache</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='ivar'>@hash</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_save'>save</span> <span class='op'>&&</span> <span class='id identifier rubyid_cache'>cache</span>
|
1618
1619
|
<span class='ivar'>@updated_at</span>
|
1619
1620
|
<span class='kw'>end</span>
|
1620
1621
|
|
1621
1622
|
<span class='comment'># Checks if the entry is still valid.
|
1622
1623
|
</span> <span class='comment'>#
|
1623
|
-
</span> <span class='comment'># @param
|
1624
|
+
</span> <span class='comment'># @param backend [Backends::Base] The backend to use for the check.
|
1624
1625
|
</span> <span class='comment'># @return [Boolean] `true` if the entry is still valid, `false` otherwise.
|
1625
|
-
</span> <span class='kw'>def</span> <span class='id identifier rubyid_valid?'>valid?</span><span class='lparen'>(</span><span class='id identifier
|
1626
|
-
<span class='id identifier
|
1627
|
-
<span class='id identifier rubyid_provider'>provider</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span> <span class='op'>-</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_updated_at'>updated_at</span> <span class='op'><</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_ttl'>ttl</span> <span class='op'>/</span> <span class='int'>1000</span>
|
1626
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_valid?'>valid?</span><span class='lparen'>(</span><span class='id identifier rubyid_backend'>backend</span><span class='rparen'>)</span>
|
1627
|
+
<span class='id identifier rubyid_backend'>backend</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span> <span class='op'>-</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_updated_at'>updated_at</span> <span class='op'><</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_ttl'>ttl</span> <span class='op'>/</span> <span class='int'>1000</span>
|
1628
1628
|
<span class='kw'>end</span>
|
1629
1629
|
|
1630
1630
|
<span class='comment'># Compares to another Entry.
|
@@ -1978,7 +1978,7 @@
|
|
1978
1978
|
<div class="method_details ">
|
1979
1979
|
<h3 class="signature " id="refresh-instance_method">
|
1980
1980
|
|
1981
|
-
- (<tt>Float</tt>) <strong>refresh</strong>(save = false)
|
1981
|
+
- (<tt>Float</tt>) <strong>refresh</strong>(save = false, cache = nil)
|
1982
1982
|
|
1983
1983
|
|
1984
1984
|
|
@@ -2012,6 +2012,23 @@
|
|
2012
2012
|
|
2013
2013
|
</li>
|
2014
2014
|
|
2015
|
+
<li>
|
2016
|
+
|
2017
|
+
<span class='name'>cache</span>
|
2018
|
+
|
2019
|
+
|
2020
|
+
<span class='type'>(<tt><span class='object_link'><a href="Cache.html" title="Elephas::Cache (class)">Cache</a></span></tt>)</span>
|
2021
|
+
|
2022
|
+
|
2023
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
2024
|
+
|
2025
|
+
|
2026
|
+
—
|
2027
|
+
<div class='inline'><p>The cache where to save the entry.</p>
|
2028
|
+
</div>
|
2029
|
+
|
2030
|
+
</li>
|
2031
|
+
|
2015
2032
|
</ul>
|
2016
2033
|
|
2017
2034
|
<p class="tag_title">Returns:</p>
|
@@ -2038,18 +2055,18 @@
|
|
2038
2055
|
<pre class="lines">
|
2039
2056
|
|
2040
2057
|
|
2041
|
-
45
|
2042
2058
|
46
|
2043
2059
|
47
|
2044
2060
|
48
|
2045
|
-
49
|
2061
|
+
49
|
2062
|
+
50</pre>
|
2046
2063
|
</td>
|
2047
2064
|
<td>
|
2048
|
-
<pre class="code"><span class="info file"># File 'lib/elephas/entry.rb', line
|
2065
|
+
<pre class="code"><span class="info file"># File 'lib/elephas/entry.rb', line 46</span>
|
2049
2066
|
|
2050
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_refresh'>refresh</span><span class='lparen'>(</span><span class='id identifier rubyid_save'>save</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
2067
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_refresh'>refresh</span><span class='lparen'>(</span><span class='id identifier rubyid_save'>save</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_cache'>cache</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
2051
2068
|
<span class='ivar'>@updated_at</span> <span class='op'>=</span> <span class='id identifier rubyid_get_new_updated_at'>get_new_updated_at</span><span class='lparen'>(</span><span class='ivar'>@updated_at</span><span class='rparen'>)</span>
|
2052
|
-
<span class='
|
2069
|
+
<span class='id identifier rubyid_cache'>cache</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='ivar'>@hash</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_save'>save</span> <span class='op'>&&</span> <span class='id identifier rubyid_cache'>cache</span>
|
2053
2070
|
<span class='ivar'>@updated_at</span>
|
2054
2071
|
<span class='kw'>end</span></pre>
|
2055
2072
|
</td>
|
@@ -2060,7 +2077,7 @@
|
|
2060
2077
|
<div class="method_details ">
|
2061
2078
|
<h3 class="signature " id="valid?-instance_method">
|
2062
2079
|
|
2063
|
-
- (<tt>Boolean</tt>) <strong>valid?</strong>(
|
2080
|
+
- (<tt>Boolean</tt>) <strong>valid?</strong>(backend)
|
2064
2081
|
|
2065
2082
|
|
2066
2083
|
|
@@ -2079,17 +2096,15 @@
|
|
2079
2096
|
|
2080
2097
|
<li>
|
2081
2098
|
|
2082
|
-
<span class='name'>
|
2083
|
-
|
2099
|
+
<span class='name'>backend</span>
|
2084
2100
|
|
2085
|
-
<span class='type'>(<tt>Provider::Base</tt>)</span>
|
2086
2101
|
|
2102
|
+
<span class='type'>(<tt><span class='object_link'><a href="Backends/Base.html" title="Elephas::Backends::Base (class)">Backends::Base</a></span></tt>)</span>
|
2087
2103
|
|
2088
|
-
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
2089
2104
|
|
2090
2105
|
|
2091
2106
|
—
|
2092
|
-
<div class='inline'><p>The
|
2107
|
+
<div class='inline'><p>The backend to use for the check.</p>
|
2093
2108
|
</div>
|
2094
2109
|
|
2095
2110
|
</li>
|
@@ -2120,17 +2135,15 @@
|
|
2120
2135
|
<pre class="lines">
|
2121
2136
|
|
2122
2137
|
|
2123
|
-
55
|
2124
2138
|
56
|
2125
2139
|
57
|
2126
2140
|
58</pre>
|
2127
2141
|
</td>
|
2128
2142
|
<td>
|
2129
|
-
<pre class="code"><span class="info file"># File 'lib/elephas/entry.rb', line
|
2143
|
+
<pre class="code"><span class="info file"># File 'lib/elephas/entry.rb', line 56</span>
|
2130
2144
|
|
2131
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_valid?'>valid?</span><span class='lparen'>(</span><span class='id identifier
|
2132
|
-
<span class='id identifier
|
2133
|
-
<span class='id identifier rubyid_provider'>provider</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span> <span class='op'>-</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_updated_at'>updated_at</span> <span class='op'><</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_ttl'>ttl</span> <span class='op'>/</span> <span class='int'>1000</span>
|
2145
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_valid?'>valid?</span><span class='lparen'>(</span><span class='id identifier rubyid_backend'>backend</span><span class='rparen'>)</span>
|
2146
|
+
<span class='id identifier rubyid_backend'>backend</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span> <span class='op'>-</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_updated_at'>updated_at</span> <span class='op'><</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_ttl'>ttl</span> <span class='op'>/</span> <span class='int'>1000</span>
|
2134
2147
|
<span class='kw'>end</span></pre>
|
2135
2148
|
</td>
|
2136
2149
|
</tr>
|
@@ -2142,7 +2155,7 @@
|
|
2142
2155
|
</div>
|
2143
2156
|
|
2144
2157
|
<div id="footer">
|
2145
|
-
Generated on
|
2158
|
+
Generated on Sun Mar 24 12:12:01 2013 by
|
2146
2159
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
2147
2160
|
0.8.5.2 (ruby-1.9.3).
|
2148
2161
|
</div>
|
data/doc/Elephas/Version.html
CHANGED
@@ -119,7 +119,7 @@
|
|
119
119
|
|
120
120
|
</div>
|
121
121
|
</dt>
|
122
|
-
<dd><pre class="code"><span class='int'>
|
122
|
+
<dd><pre class="code"><span class='int'>3</span></pre></dd>
|
123
123
|
|
124
124
|
<dt id="MINOR-constant" class="">MINOR =
|
125
125
|
<div class="docstring">
|
@@ -134,7 +134,7 @@
|
|
134
134
|
|
135
135
|
</div>
|
136
136
|
</dt>
|
137
|
-
<dd><pre class="code"><span class='int'>
|
137
|
+
<dd><pre class="code"><span class='int'>0</span></pre></dd>
|
138
138
|
|
139
139
|
<dt id="PATCH-constant" class="">PATCH =
|
140
140
|
<div class="docstring">
|
@@ -180,7 +180,7 @@
|
|
180
180
|
</div>
|
181
181
|
|
182
182
|
<div id="footer">
|
183
|
-
Generated on
|
183
|
+
Generated on Sun Mar 24 12:12:01 2013 by
|
184
184
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
185
185
|
0.8.5.2 (ruby-1.9.3).
|
186
186
|
</div>
|
data/doc/Elephas.html
CHANGED
@@ -80,7 +80,7 @@
|
|
80
80
|
|
81
81
|
<dt class="r1 last">Defined in:</dt>
|
82
82
|
<dd class="r1 last">lib/elephas/entry.rb<span class="defines">,<br />
|
83
|
-
lib/elephas/cache.rb,<br /> lib/elephas/version.rb,<br /> lib/elephas/
|
83
|
+
lib/elephas/cache.rb,<br /> lib/elephas/version.rb,<br /> lib/elephas/backends/hash.rb,<br /> lib/elephas/backends/base.rb,<br /> lib/elephas/backends/ruby_on_rails.rb</span>
|
84
84
|
</dd>
|
85
85
|
|
86
86
|
</dl>
|
@@ -101,7 +101,7 @@ Licensed under the MIT license, which can be found at http://www.opensource.org/
|
|
101
101
|
<p class="children">
|
102
102
|
|
103
103
|
|
104
|
-
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Elephas/
|
104
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Elephas/Backends.html" title="Elephas::Backends (module)">Backends</a></span>, <span class='object_link'><a href="Elephas/Version.html" title="Elephas::Version (module)">Version</a></span>
|
105
105
|
|
106
106
|
|
107
107
|
|
@@ -121,7 +121,7 @@ Licensed under the MIT license, which can be found at http://www.opensource.org/
|
|
121
121
|
</div>
|
122
122
|
|
123
123
|
<div id="footer">
|
124
|
-
Generated on
|
124
|
+
Generated on Sun Mar 24 12:12:01 2013 by
|
125
125
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
126
126
|
0.8.5.2 (ruby-1.9.3).
|
127
127
|
</div>
|
data/doc/_index.html
CHANGED
@@ -85,9 +85,16 @@
|
|
85
85
|
<ul>
|
86
86
|
|
87
87
|
<li>
|
88
|
-
<span class='object_link'><a href="Elephas/
|
88
|
+
<span class='object_link'><a href="Elephas/Backends.html" title="Elephas::Backends (module)">Backends</a></span>
|
89
89
|
|
90
|
-
<small>(Elephas
|
90
|
+
<small>(Elephas)</small>
|
91
|
+
|
92
|
+
</li>
|
93
|
+
|
94
|
+
<li>
|
95
|
+
<span class='object_link'><a href="Elephas/Backends/Base.html" title="Elephas::Backends::Base (class)">Base</a></span>
|
96
|
+
|
97
|
+
<small>(Elephas::Backends)</small>
|
91
98
|
|
92
99
|
</li>
|
93
100
|
|
@@ -135,24 +142,9 @@
|
|
135
142
|
<ul>
|
136
143
|
|
137
144
|
<li>
|
138
|
-
<span class='object_link'><a href="Elephas/
|
139
|
-
|
140
|
-
<small>(Elephas::Providers)</small>
|
141
|
-
|
142
|
-
</li>
|
143
|
-
|
144
|
-
</ul>
|
145
|
-
</ul>
|
146
|
-
|
147
|
-
|
148
|
-
<ul id="alpha_P" class="alpha">
|
149
|
-
<li class="letter">P</li>
|
150
|
-
<ul>
|
151
|
-
|
152
|
-
<li>
|
153
|
-
<span class='object_link'><a href="Elephas/Providers.html" title="Elephas::Providers (module)">Providers</a></span>
|
145
|
+
<span class='object_link'><a href="Elephas/Backends/Hash.html" title="Elephas::Backends::Hash (class)">Hash</a></span>
|
154
146
|
|
155
|
-
<small>(Elephas)</small>
|
147
|
+
<small>(Elephas::Backends)</small>
|
156
148
|
|
157
149
|
</li>
|
158
150
|
|
@@ -165,9 +157,9 @@
|
|
165
157
|
<ul>
|
166
158
|
|
167
159
|
<li>
|
168
|
-
<span class='object_link'><a href="Elephas/
|
160
|
+
<span class='object_link'><a href="Elephas/Backends/RubyOnRails.html" title="Elephas::Backends::RubyOnRails (class)">RubyOnRails</a></span>
|
169
161
|
|
170
|
-
<small>(Elephas::
|
162
|
+
<small>(Elephas::Backends)</small>
|
171
163
|
|
172
164
|
</li>
|
173
165
|
|
@@ -198,7 +190,7 @@
|
|
198
190
|
</div>
|
199
191
|
|
200
192
|
<div id="footer">
|
201
|
-
Generated on
|
193
|
+
Generated on Sun Mar 24 12:12:01 2013 by
|
202
194
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
203
195
|
0.8.5.2 (ruby-1.9.3).
|
204
196
|
</div>
|
data/doc/class_list.html
CHANGED
@@ -45,7 +45,7 @@
|
|
45
45
|
|
46
46
|
<ul id="full_list" class="class">
|
47
47
|
<li><span class='object_link'><a href="top-level-namespace.html" title=" (root)">Top Level Namespace</a></span></li>
|
48
|
-
<li><a class='toggle'></a> <span class='object_link'><a href="Elephas.html" title="Elephas (module)">Elephas</a></span><small class='search_info'>Top Level Namespace</small></li><ul><li><span class='object_link'><a href="Elephas/
|
48
|
+
<li><a class='toggle'></a> <span class='object_link'><a href="Elephas.html" title="Elephas (module)">Elephas</a></span><small class='search_info'>Top Level Namespace</small></li><ul><li><a class='toggle'></a> <span class='object_link'><a href="Elephas/Backends.html" title="Elephas::Backends (module)">Backends</a></span><small class='search_info'>Elephas</small></li><ul><li><span class='object_link'><a href="Elephas/Backends/Base.html" title="Elephas::Backends::Base (class)">Base</a></span> < Object<small class='search_info'>Elephas::Backends</small></li><li><span class='object_link'><a href="Elephas/Backends/Hash.html" title="Elephas::Backends::Hash (class)">Hash</a></span> < Base<small class='search_info'>Elephas::Backends</small></li><li><span class='object_link'><a href="Elephas/Backends/RubyOnRails.html" title="Elephas::Backends::RubyOnRails (class)">RubyOnRails</a></span> < Base<small class='search_info'>Elephas::Backends</small></li></ul><li><span class='object_link'><a href="Elephas/Cache.html" title="Elephas::Cache (class)">Cache</a></span> < Object<small class='search_info'>Elephas</small></li><li><span class='object_link'><a href="Elephas/Entry.html" title="Elephas::Entry (class)">Entry</a></span> < Object<small class='search_info'>Elephas</small></li><li><span class='object_link'><a href="Elephas/Version.html" title="Elephas::Version (module)">Version</a></span><small class='search_info'>Elephas</small></li></ul>
|
49
49
|
|
50
50
|
</ul>
|
51
51
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -78,10 +78,10 @@
|
|
78
78
|
|
79
79
|
<p>The usage of the framework is really simple.</p>
|
80
80
|
|
81
|
-
<p>At first you have to setup a
|
81
|
+
<p>At first you have to setup a cache object with a backend (that is, a storage) for the Elephas. By default it uses an internal hash, and also Rails is supported.</p>
|
82
82
|
|
83
83
|
<p><code>ruby
|
84
|
-
Elephas::Cache.
|
84
|
+
cache = Elephas::Cache.new(Elephas::Backends::RubyOnRails.new)
|
85
85
|
</code></p>
|
86
86
|
|
87
87
|
<p>After that, you can query the framework for a value use the <code>use</code> method.</p>
|
@@ -89,7 +89,7 @@ Elephas::Cache.provider = Elephas::Providers::RubyOnRails.new
|
|
89
89
|
<p>You should also pass a block to the method, so that the framework use that for computing the value of the cache entry.</p>
|
90
90
|
|
91
91
|
<p><code>ruby
|
92
|
-
value =
|
92
|
+
value = cache.use("KEY") do |options|
|
93
93
|
"VALUE"
|
94
94
|
end
|
95
95
|
# => "VALUE"
|
@@ -99,7 +99,7 @@ end
|
|
99
99
|
|
100
100
|
<p>The block takes an argument, which contains all the options for the entry.</p>
|
101
101
|
|
102
|
-
<p>You can see <code>Elephas::Cache
|
102
|
+
<p>You can see <code>Elephas::Cache#setup_options</code> documentation to see what options are supported.</p>
|
103
103
|
|
104
104
|
<p>For now, you just have to know that you can set the <code>:ttl</code> option to specify how long the value will stay in the cache (in milliseconds). Setting it to a non-positive value means to never cache the value.</p>
|
105
105
|
|
@@ -127,7 +127,7 @@ end
|
|
127
127
|
</div></div>
|
128
128
|
|
129
129
|
<div id="footer">
|
130
|
-
Generated on
|
130
|
+
Generated on Sun Mar 24 12:12:01 2013 by
|
131
131
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
132
132
|
0.8.5.2 (ruby-1.9.3).
|
133
133
|
</div>
|
data/doc/index.html
CHANGED
@@ -78,10 +78,10 @@
|
|
78
78
|
|
79
79
|
<p>The usage of the framework is really simple.</p>
|
80
80
|
|
81
|
-
<p>At first you have to setup a
|
81
|
+
<p>At first you have to setup a cache object with a backend (that is, a storage) for the Elephas. By default it uses an internal hash, and also Rails is supported.</p>
|
82
82
|
|
83
83
|
<p><code>ruby
|
84
|
-
Elephas::Cache.
|
84
|
+
cache = Elephas::Cache.new(Elephas::Backends::RubyOnRails.new)
|
85
85
|
</code></p>
|
86
86
|
|
87
87
|
<p>After that, you can query the framework for a value use the <code>use</code> method.</p>
|
@@ -89,7 +89,7 @@ Elephas::Cache.provider = Elephas::Providers::RubyOnRails.new
|
|
89
89
|
<p>You should also pass a block to the method, so that the framework use that for computing the value of the cache entry.</p>
|
90
90
|
|
91
91
|
<p><code>ruby
|
92
|
-
value =
|
92
|
+
value = cache.use("KEY") do |options|
|
93
93
|
"VALUE"
|
94
94
|
end
|
95
95
|
# => "VALUE"
|
@@ -99,7 +99,7 @@ end
|
|
99
99
|
|
100
100
|
<p>The block takes an argument, which contains all the options for the entry.</p>
|
101
101
|
|
102
|
-
<p>You can see <code>Elephas::Cache
|
102
|
+
<p>You can see <code>Elephas::Cache#setup_options</code> documentation to see what options are supported.</p>
|
103
103
|
|
104
104
|
<p>For now, you just have to know that you can set the <code>:ttl</code> option to specify how long the value will stay in the cache (in milliseconds). Setting it to a non-positive value means to never cache the value.</p>
|
105
105
|
|
@@ -127,7 +127,7 @@ end
|
|
127
127
|
</div></div>
|
128
128
|
|
129
129
|
<div id="footer">
|
130
|
-
Generated on
|
130
|
+
Generated on Sun Mar 24 12:12:01 2013 by
|
131
131
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
132
132
|
0.8.5.2 (ruby-1.9.3).
|
133
133
|
</div>
|