doc/Elephas/Backends/RubyOnRails.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
Class: Elephas::Backends::RubyOnRails
— Documentation by YARD 0.8.6.2
</title>
<link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
<script type="text/javascript" charset="utf-8">
hasFrames = window.top.frames.main ? true : false;
relpath = '../../';
framesUrl = "../../frames.html#!" + escape(window.location.href);
</script>
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
</head>
<body>
<div id="header">
<div id="menu">
<a href="../../_index.html">Index (R)</a> »
<span class='title'><span class='object_link'><a href="../../Elephas.html" title="Elephas (module)">Elephas</a></span></span> » <span class='title'><span class='object_link'><a href="../Backends.html" title="Elephas::Backends (module)">Backends</a></span></span>
»
<span class="title">RubyOnRails</span>
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>
<div id="search">
<a class="full_list_link" id="class_list_link"
href="../../class_list.html">
Class List
</a>
<a class="full_list_link" id="method_list_link"
href="../../method_list.html">
Method List
</a>
<a class="full_list_link" id="file_list_link"
href="../../file_list.html">
File List
</a>
</div>
<div class="clear"></div>
</div>
<iframe id="search_frame"></iframe>
<div id="content"><h1>Class: Elephas::Backends::RubyOnRails
</h1>
<dl class="box">
<dt class="r1">Inherits:</dt>
<dd class="r1">
<span class="inheritName"><span class='object_link'><a href="Base.html" title="Elephas::Backends::Base (class)">Base</a></span></span>
<ul class="fullTree">
<li>Object</li>
<li class="next"><span class='object_link'><a href="Base.html" title="Elephas::Backends::Base (class)">Base</a></span></li>
<li class="next">Elephas::Backends::RubyOnRails</li>
</ul>
<a href="#" class="inheritanceTree">show all</a>
</dd>
<dt class="r2 last">Defined in:</dt>
<dd class="r2 last">lib/elephas/backends/ruby_on_rails.rb</dd>
</dl>
<div class="clear"></div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>This is a Ruby on Rails backend, which uses Rails.cache.</p>
</div>
</div>
<div class="tags">
</div>
<h2>
Instance Method Summary
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#delete-instance_method" title="#delete (instance 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-instance_method" title="#exists? (instance method)">- (Boolean) <strong>exists?</strong>(key) </a>
</span>
<span class="summary_desc"><div class='inline'><p>Checks if a key exists in the cache.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#read-instance_method" title="#read (instance method)">- (Entry|NilClass) <strong>read</strong>(key) </a>
</span>
<span class="summary_desc"><div class='inline'><p>Reads a value from the cache.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#write-instance_method" title="#write (instance method)">- (Object) <strong>write</strong>(key, value, options = {}) </a>
</span>
<span class="summary_desc"><div class='inline'><p>Writes a value to the cache.</p>
</div></span>
</li>
</ul>
<h3 class="inherited">Methods inherited from <span class='object_link'><a href="Base.html" title="Elephas::Backends::Base (class)">Base</a></span></h3>
<p class="inherited"><span class='object_link'><a href="Base.html#now-instance_method" title="Elephas::Backends::Base#now (method)">#now</a></span></p>
<div id="instance_method_details" class="method_details_list">
<h2>Instance Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="delete-instance_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>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>key</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>The key to delete.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<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>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
37
38
39
40
41</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/elephas/backends/ruby_on_rails.rb', line 37</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='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='const'>Rails</span><span class='period'>.</span><span class='id identifier rubyid_cache'>cache</span><span class='period'>.</span><span class='id identifier rubyid_exist?'>exist?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
<span class='const'>Rails</span><span class='period'>.</span><span class='id identifier rubyid_cache'>cache</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='id identifier rubyid_rv'>rv</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="exists?-instance_method">
- (<tt>Boolean</tt>) <strong>exists?</strong>(key)
</h3><div class="docstring">
<div class="discussion">
<p>Checks if a key exists in the cache.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>key</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>The key to lookup.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<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>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
47
48
49</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/elephas/backends/ruby_on_rails.rb', line 47</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='const'>Rails</span><span class='period'>.</span><span class='id identifier rubyid_cache'>cache</span><span class='period'>.</span><span class='id identifier rubyid_exist?'>exist?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='const'>Rails</span><span class='period'>.</span><span class='id identifier rubyid_cache'>cache</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='period'>.</span><span class='id identifier rubyid_valid?'>valid?</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="read-instance_method">
- (<tt><span class='object_link'><a href="../Entry.html" title="Elephas::Entry (class)">Entry</a></span>|NilClass</tt>) <strong>read</strong>(key)
</h3><div class="docstring">
<div class="discussion">
<p>Reads a value from the cache.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>key</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>The key to lookup.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt><span class='object_link'><a href="../Entry.html" title="Elephas::Entry (class)">Entry</a></span>|NilClass</tt>)</span>
—
<div class='inline'><p>The read value or <code>nil</code>.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
15
16
17</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/elephas/backends/ruby_on_rails.rb', line 15</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='id identifier rubyid_exists?'>exists?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='const'>Rails</span><span class='period'>.</span><span class='id identifier rubyid_cache'>cache</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='op'>:</span> <span class='kw'>nil</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="write-instance_method">
- (<tt>Object</tt>) <strong>write</strong>(key, value, options = {})
</h3><div class="docstring">
<div class="discussion">
<p>Writes a value to the cache.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>key</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>The key to associate the value with.</p>
</div>
</li>
<li>
<span class='name'>value</span>
<span class='type'>(<tt>Object</tt>)</span>
—
<div class='inline'><p>The value to write. <strong>Setting a value to <code>nil</code> **doesn’t</strong> mean <em>deleting</em> the value.</p>
</div>
</li>
<li>
<span class='name'>options</span>
<span class='type'>(<tt><span class='object_link'><a href="Hash.html" title="Elephas::Backends::Hash (class)">Hash</a></span></tt>)</span>
<em class="default">(defaults to: <tt>{}</tt>)</em>
—
<div class='inline'><p>A list of options for writing.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Object</tt>)</span>
—
<div class='inline'><p>The value itself.</p>
</div>
</li>
</ul>
<p class="tag_title">See Also:</p>
<ul class="see">
<li>Cache.setup_options</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
26
27
28
29
30
31</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/elephas/backends/ruby_on_rails.rb', line 26</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='id identifier rubyid_entry'>entry</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_value'>value</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='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_refresh'>refresh</span>
<span class='const'>Rails</span><span class='period'>.</span><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='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_entry'>entry</span><span class='comma'>,</span> <span class='label'>expires_in:</span> <span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_ttl'>ttl</span><span class='rparen'>)</span>
<span class='id identifier rubyid_entry'>entry</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Sat Jul 20 13:31:56 2013 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.8.6.2 (ruby-1.9.3).
</div>
</body>
</html>