doc/Elephas/Cache.html in elephas-0.1.0 vs doc/Elephas/Cache.html in elephas-1.0.0
- old
+ new
@@ -156,11 +156,11 @@
<ul class="summary">
<li class="public ">
<span class="summary_signature">
- <a href="#delete-class_method" title="delete (class method)">+ (TrueClass|FalseClass) <strong>delete</strong>(key) </a>
+ <a href="#default_prefix-class_method" title="default_prefix (class method)">+ (String) <strong>default_prefix</strong> </a>
</span>
@@ -170,20 +170,43 @@
+ <span class="summary_desc"><div class='inline'><p>Returns the default prefix for cache entries.</p>
+</div></span>
+
+</li>
+
+
+ <li class="public ">
+ <span class="summary_signature">
+
+ <a href="#delete-class_method" title="delete (class method)">+ (Boolean) <strong>delete</strong>(key) </a>
+
+
+
+ </span>
+
+
+
+
+
+
+
+
+
<span class="summary_desc"><div class='inline'><p>Deletes a value from the cache.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
- <a href="#exists%3F-class_method" title="exists? (class method)">+ (TrueClass|FalseClass) <strong>exists?</strong>(key) </a>
+ <a href="#exists%3F-class_method" title="exists? (class method)">+ (Boolean) <strong>exists?</strong>(key) </a>
</span>
@@ -225,10 +248,33 @@
<li class="public ">
<span class="summary_signature">
+ <a href="#setup_options-class_method" title="setup_options (class method)">+ (Hash) <strong>setup_options</strong>(options, key) </a>
+
+
+
+ </span>
+
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'><p>Setups options for use into the framework.</p>
+</div></span>
+
+</li>
+
+
+ <li class="public ">
+ <span class="summary_signature">
+
<a href="#use-class_method" title="use (class method)">+ (Object|Entry) <strong>use</strong>(key, options = {}) </a>
</span>
@@ -325,20 +371,77 @@
<div id="class_method_details" class="method_details_list">
<h2>Class Method Details</h2>
<div class="method_details first">
- <h3 class="signature first" id="delete-class_method">
+ <h3 class="signature first" id="default_prefix-class_method">
- + (<tt>TrueClass|FalseClass</tt>) <strong>delete</strong>(key)
+ + (<tt>String</tt>) <strong>default_prefix</strong>
</h3><div class="docstring">
<div class="discussion">
+ <p>Returns the default prefix for cache entries.</p>
+
+
+ </div>
+</div>
+<div class="tags">
+
+<p class="tag_title">Returns:</p>
+<ul class="return">
+
+ <li>
+
+
+ <span class='type'>(<tt>String</tt>)</span>
+
+
+
+ —
+ <div class='inline'><p>The default prefix for cache entries.</p>
+</div>
+
+ </li>
+
+</ul>
+
+</div><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+96
+97
+98</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'lib/elephas/cache.rb', line 96</span>
+
+<span class='kw'>def</span> <span class='id identifier rubyid_default_prefix'>default_prefix</span>
+ <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>elephas-</span><span class='embexpr_beg'>#{</span><span class='op'>::</span><span class='const'>Elephas</span><span class='op'>::</span><span class='const'>Version</span><span class='op'>::</span><span class='const'>STRING</span><span class='rbrace'>}</span><span class='tstring_content'>-cache</span><span class='tstring_end'>"</span></span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+ <div class="method_details ">
+ <h3 class="signature " id="delete-class_method">
+
+ + (<tt>Boolean</tt>) <strong>delete</strong>(key)
+
+
+
+
+
+</h3><div class="docstring">
+ <div class="discussion">
<p>Deletes a value from the cache.</p>
</div>
</div>
@@ -367,11 +470,11 @@
<ul class="return">
<li>
- <span class='type'>(<tt>TrueClass|FalseClass</tt>)</span>
+ <span class='type'>(<tt>Boolean</tt>)</span>
—
<div class='inline'><p><code>true</code> if the key was in the cache, <code>false</code> otherwise.</p>
@@ -385,16 +488,16 @@
<tr>
<td>
<pre class="lines">
-76
-77
-78</pre>
+81
+82
+83</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/elephas/cache.rb', line 76</span>
+ <pre class="code"><span class="info file"># File 'lib/elephas/cache.rb', line 81</span>
<span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_provider'>provider</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
@@ -403,11 +506,11 @@
</div>
<div class="method_details ">
<h3 class="signature " id="exists?-class_method">
- + (<tt>TrueClass|FalseClass</tt>) <strong>exists?</strong>(key)
+ + (<tt>Boolean</tt>) <strong>exists?</strong>(key)
@@ -443,11 +546,11 @@
<ul class="return">
<li>
- <span class='type'>(<tt>TrueClass|FalseClass</tt>)</span>
+ <span class='type'>(<tt>Boolean</tt>)</span>
—
<div class='inline'><p><code>true</code> if the key is in the cache, <code>false</code> otherwise.</p>
@@ -461,16 +564,16 @@
<tr>
<td>
<pre class="lines">
-84
-85
-86</pre>
+89
+90
+91</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/elephas/cache.rb', line 84</span>
+ <pre class="code"><span class="info file"># File 'lib/elephas/cache.rb', line 89</span>
<span class='kw'>def</span> <span class='id identifier rubyid_exists?'>exists?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_provider'>provider</span><span class='period'>.</span><span class='id identifier rubyid_exists?'>exists?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
@@ -537,40 +640,186 @@
<tr>
<td>
<pre class="lines">
-55
-56
-57</pre>
+62
+63
+64</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/elephas/cache.rb', line 55</span>
+ <pre class="code"><span class="info file"># File 'lib/elephas/cache.rb', line 62</span>
<span class='kw'>def</span> <span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_provider'>provider</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
+ <h3 class="signature " id="setup_options-class_method">
+
+ + (<tt>Hash</tt>) <strong>setup_options</strong>(options, key)
+
+
+
+
+
+</h3><div class="docstring">
+ <div class="discussion">
+ <p>Setups options for use into the framework.
+Valid options are:</p>
+
+<ul>
+<li><strong>:ttl</strong>: The TTL (time to live, in milliseconds) of the entry. It means how long will the value stay in cache. Setting it to 0 or less means never cache the entry.</li>
+<li><strong>:force</strong>: Setting it to <code>true</code> will always skip the cache.</li>
+<li><strong>:key</strong>: The key associated to this value. <strong>You should never set this option directly.</strong></li>
+<li><strong>:prefix</strong>: The prefix used in cache. This is used to avoid conflicts with other caching frameworks.</li>
+<li><strong>:complete_key</strong>: The complete key used for computing the hash. By default is concatenation of <code>:key</code> and <code>:prefix</code> options.</li>
+<li><strong>:hash</strong>: The hash used to store the key in the cache. Should be unique</li>
+<li><strong>:as_entry</strong>: In <code>Elephas::Cache.use</code>, setting this to <code>true</code> will return the entire <code>Entry</code> object rather than the value only.</li>
+</ul>
+
+
+ </div>
+</div>
+<div class="tags">
+ <p class="tag_title">Parameters:</p>
+<ul class="param">
+
+ <li>
+
+ <span class='name'>options</span>
+
+
+ <span class='type'>(<tt>Object</tt>)</span>
+
+
+
+ —
+ <div class='inline'><p>An initial setup.</p>
+</div>
+
+ </li>
+
+ <li>
+
+ <span class='name'>key</span>
+
+
+ <span class='type'>(<tt>String</tt>)</span>
+
+
+
+ —
+ <div class='inline'><p>The key to associate to this options.</p>
+</div>
+
+ </li>
+
+</ul>
+
+<p class="tag_title">Returns:</p>
+<ul class="return">
+
+ <li>
+
+
+ <span class='type'>(<tt>Hash</tt>)</span>
+
+
+
+ —
+ <div class='inline'><p>An options hash.</p>
+</div>
+
+ </li>
+
+</ul>
+
+</div><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'lib/elephas/cache.rb', line 114</span>
+
+<span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
+ <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span>
+ <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='symbol'>:ttl</span> <span class='op'>=></span> <span class='int'>1</span><span class='period'>.</span><span class='id identifier rubyid_hour'>hour</span> <span class='op'>*</span> <span class='int'>1000</span><span class='comma'>,</span> <span class='symbol'>:force</span> <span class='op'>=></span> <span class='kw'>false</span><span class='comma'>,</span> <span class='symbol'>:as_entry</span> <span class='op'>=></span> <span class='kw'>false</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
+ <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:key</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
+ <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:ttl</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:ttl</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>?</span> <span class='int'>1</span><span class='period'>.</span><span class='id identifier rubyid_hour'>hour</span> <span class='op'>*</span> <span class='int'>1000</span> <span class='op'>:</span> <span class='lbracket'>[</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:ttl</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_integer'>to_integer</span><span class='comma'>,</span> <span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span>
+ <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:force</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:force</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_boolean'>to_boolean</span>
+ <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:prefix</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:prefix</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:prefix</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>elephas-</span><span class='embexpr_beg'>#{</span><span class='op'>::</span><span class='const'>Elephas</span><span class='op'>::</span><span class='const'>Version</span><span class='op'>::</span><span class='const'>STRING</span><span class='rbrace'>}</span><span class='tstring_content'>-cache</span><span class='tstring_end'>"</span></span>
+
+ <span class='comment'># Wrap the final key to ensure we don't have colliding namespaces.
+</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:complete_key</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:prefix</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:key</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='tstring_content'>]</span><span class='tstring_end'>"</span></span>
+
+ <span class='comment'># Compute the hash key used for referencing this value
+</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:hash</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='op'>::</span><span class='const'>Elephas</span><span class='op'>::</span><span class='const'>Entry</span><span class='period'>.</span><span class='id identifier rubyid_hashify_key'>hashify_key</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:complete_key</span><span class='rbracket'>]</span><span class='rparen'>)</span>
+
+ <span class='id identifier rubyid_options'>options</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+ <div class="method_details ">
<h3 class="signature " id="use-class_method">
+ (<tt>Object|<span class='object_link'><a href="Entry.html" title="Elephas::Entry (class)">Entry</a></span></tt>) <strong>use</strong>(key, options = {})
</h3><div class="docstring">
<div class="discussion">
- <p>This is the main method of the framework.
-It tries reading a key from the cache. If it doesn't find it, it uses the provided block to compute its value and then store it into the cache for later usages.</p>
+ <p>This is the main method of the framework.</p>
+<p>It tries reading a key from the cache.</p>
+<p>If it doesn't find it, it uses the provided block (which receives options as argument) to compute its value and then store it into the cache for later usages.</p>
+
+<pre class="code ruby"><code><span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='const'>Elephas</span><span class='op'>::</span><span class='const'>Cache</span><span class='period'>.</span><span class='id identifier rubyid_use'>use</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>KEY</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_options'>options</span><span class='op'>|</span>
+ <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>VALUE</span><span class='tstring_end'>"</span></span>
+<span class='kw'>end</span>
+
+<span class='id identifier rubyid_value'>value</span>
+<span class='comment'># => "VALUE"
+</span>
+<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='const'>Elephas</span><span class='op'>::</span><span class='const'>Cache</span><span class='period'>.</span><span class='id identifier rubyid_use'>use</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>KEY</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_options'>options</span><span class='op'>|</span>
+ <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>ANOTHER VALUE</span><span class='tstring_end'>"</span></span>
+<span class='kw'>end</span>
+
+<span class='id identifier rubyid_value'>value</span>
+<span class='comment'># => "VALUE"
+</span></code></pre>
+
+
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
@@ -608,79 +857,60 @@
</li>
</ul>
+ <p class="tag_title">See Also:</p>
+ <ul class="see">
+
+ <li></li>
+
+ </ul>
+
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
39
40
41
42
43
44
45
46
47
48
-49</pre>
+49
+50
+51
+52
+53
+54
+55
+56</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/elephas/cache.rb', line 19</span>
+ <pre class="code"><span class="info file"># File 'lib/elephas/cache.rb', line 39</span>
<span class='kw'>def</span> <span class='id identifier rubyid_use'>use</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='kw'>nil</span>
<span class='comment'># Get options
-</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span>
- <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='symbol'>:ttl</span> <span class='op'>=></span> <span class='int'>1</span><span class='period'>.</span><span class='id identifier rubyid_hour'>hour</span><span class='comma'>,</span> <span class='symbol'>:force</span> <span class='op'>=></span> <span class='kw'>false</span><span class='comma'>,</span> <span class='symbol'>:as_entry</span> <span class='op'>=></span> <span class='kw'>false</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
- <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:ttl</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='lbracket'>[</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:ttl</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_integer'>to_integer</span><span class='comma'>,</span> <span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span>
- <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:force</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:force</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_boolean'>to_boolean</span>
- <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:prefix</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:prefix</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:prefix</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>elephas-</span><span class='embexpr_beg'>#{</span><span class='op'>::</span><span class='const'>Elephas</span><span class='op'>::</span><span class='const'>Version</span><span class='op'>::</span><span class='const'>STRING</span><span class='rbrace'>}</span><span class='tstring_content'>-cache</span><span class='tstring_end'>"</span></span>
+</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
- <span class='comment'># Wrap the final key to ensure we don't have colliding namespaces.
-</span> <span class='id identifier rubyid_fkey'>fkey</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:prefix</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_key'>key</span><span class='rbrace'>}</span><span class='tstring_content'>]</span><span class='tstring_end'>"</span></span>
-
- <span class='comment'># Compute the hash key used for referencing this value
-</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:hash</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:hash</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='op'>::</span><span class='const'>Elephas</span><span class='op'>::</span><span class='const'>Entry</span><span class='period'>.</span><span class='id identifier rubyid_hashify_key'>hashify_key</span><span class='lparen'>(</span><span class='id identifier rubyid_fkey'>fkey</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span>
-
<span class='comment'># Check if the storage has the value (if we don't have to skip the cache)
</span> <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_provider'>provider</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:hash</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:force</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='kw'>false</span> <span class='op'>&&</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:ttl</span><span class='rbracket'>]</span> <span class='op'>></span> <span class='int'>0</span>
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='id identifier rubyid_block_given?'>block_given?</span> <span class='kw'>then</span> <span class='comment'># Try to compute the value from the block
-</span> <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='kw'>yield</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
+</span> <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='kw'>yield</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>Elephas</span><span class='op'>::</span><span class='const'>Entry</span><span class='period'>.</span><span class='id identifier rubyid_ensure'>ensure</span><span class='lparen'>(</span><span class='id identifier rubyid_rv'>rv</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:complete_key</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span> <span class='comment'># Make sure is an entry
+</span> <span class='const'>Elephas</span><span class='op'>::</span><span class='const'>Cache</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_hash'>hash</span><span class='comma'>,</span> <span class='id identifier rubyid_rv'>rv</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:ttl</span><span class='rbracket'>]</span> <span class='op'>></span> <span class='int'>0</span> <span class='comment'># We have a value and we have to store it
+</span> <span class='kw'>end</span>
- <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span> <span class='op'>&&</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:ttl</span><span class='rbracket'>]</span> <span class='op'>></span> <span class='int'>0</span> <span class='kw'>then</span> <span class='comment'># We have a value and we have to store it
-</span> <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>Elephas</span><span class='op'>::</span><span class='const'>Entry</span><span class='period'>.</span><span class='id identifier rubyid_ensure'>ensure</span><span class='lparen'>(</span><span class='id identifier rubyid_rv'>rv</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span> <span class='comment'># Make sure is an entry
-</span> <span class='const'>Elephas</span><span class='op'>::</span><span class='const'>Cache</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_fkey'>fkey</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
- <span class='kw'>end</span>
- <span class='kw'>end</span>
-
<span class='comment'># Return value
</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:as_entry</span><span class='rbracket'>]</span> <span class='op'>?</span> <span class='id identifier rubyid_rv'>rv</span> <span class='op'>:</span> <span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_dup'>dup</span>
<span class='kw'>end</span></pre>
</td>
</tr>
@@ -698,13 +928,11 @@
</h3><div class="docstring">
<div class="discussion">
<p>Writes a value to the cache.</p>
-<p>TODO: Insert options documentation.</p>
-
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
@@ -774,29 +1002,32 @@
</li>
</ul>
+ <p class="tag_title">See Also:</p>
+ <ul class="see">
+
+ <li><span class='object_link'><a href="#setup_options-class_method" title="Elephas::Cache.setup_options (method)">setup_options</a></span></li>
+
+ </ul>
+
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
-66
-67
-68
-69
-70</pre>
+73
+74
+75</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/elephas/cache.rb', line 66</span>
+ <pre class="code"><span class="info file"># File 'lib/elephas/cache.rb', line 73</span>
<span class='kw'>def</span> <span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
- <span class='comment'># TODO: Handle options
-</span>
- <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_provider'>provider</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_provider'>provider</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
@@ -804,10 +1035,10 @@
</div>
</div>
<div id="footer">
- Generated on Sat Jul 28 14:29:52 2012 by
+ Generated on Sun Jul 29 10:32:07 2012 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.8.2.1 (ruby-1.9.2).
</div>
</body>
\ No newline at end of file