<!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=US-ASCII" />
<title>
  File: README
  
    &mdash; Documentation by YARD 0.8.3
  
</title>

  <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />

  <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" 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</a> &raquo; 
    <span class="title">File: README</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"><div id='filecontents'><h1>elephas</h1>

<p><a href="http://travis-ci.org/ShogunPanda/elephas"><img src="https://secure.travis-ci.org/ShogunPanda/elephas.png?branch=master" alt="Build Status"></a>
<a href="https://gemnasium.com/ShogunPanda/elephas"><img src="https://gemnasium.com/ShogunPanda/elephas.png?travis" alt="Dependency Status"></a>
<a href="https://codeclimate.com/github/ShogunPanda/elephas"><img src="https://codeclimate.com/github/ShogunPanda/elephas.png" alt="Code Climate"></a></p>

<p>A storage agnostic caching framework.</p>

<p><a href="http://sw.cow.tc/elephas">http://sw.cow.tc/elephas</a></p>

<p><a href="http://rdoc.info/gems/elephas">http://rdoc.info/gems/elephas</a></p>

<h2>Usage</h2>

<p>The usage of the framework is really simple.</p>

<p>At first you have to setup a provider (that is, a storage) for the Elephas. By default it uses an internal hash, and also Rails is supported.</p>

<pre class="code ruby"><code><span class='const'>Elephas</span><span class='op'>::</span><span class='const'>Cache</span><span class='period'>.</span><span class='id identifier rubyid_provider'>provider</span> <span class='op'>=</span> <span class='const'>Elephas</span><span class='op'>::</span><span class='const'>Providers</span><span class='op'>::</span><span class='const'>RubyOnRails</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
</code></pre>

<p>After that, you can query the framework for a value use the <code>use</code> method.</p>

<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>

<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'>&quot;</span><span class='tstring_content'>KEY</span><span class='tstring_end'>&quot;</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'>&quot;</span><span class='tstring_content'>VALUE</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>end</span>
<span class='comment'># =&gt; &quot;VALUE&quot;
</span></code></pre>

<p>The next time you issue this call, the block won&#39;t be called.</p>

<p>The block takes an argument, which contains all the options for the entry.</p>

<p>You can see <code>Elephas::Cache.setup_options</code> documentation to see what options are supported.</p>

<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>

<p>See documentation for more informations.</p>

<p><strong>You&#39;re done!</strong></p>

<h2>Contributing to elephas</h2>

<ul>
<li>Check out the latest master to make sure the feature hasn&#39;t been implemented or the bug hasn&#39;t been fixed yet.</li>
<li>Check out the issue tracker to make sure someone already hasn&#39;t requested it and/or contributed it.</li>
<li>Fork the project.</li>
<li>Start a feature/bugfix branch.</li>
<li>Commit and push until you are happy with your contribution.</li>
<li>Make sure to add tests for it. This is important so I don&#39;t break it in a future version unintentionally.</li>
<li>Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.</li>
</ul>

<h2>Copyright</h2>

<p>Copyright (C) 2013 and above Shogun (<a href="mailto:shogun_panda@me.com">shogun_panda@me.com</a>).</p>

<p>Licensed under the MIT license, which can be found at <a href="http://www.opensource.org/licenses/mit-license.php">http://www.opensource.org/licenses/mit-license.php</a>.</p>
</div></div>

    <div id="footer">
  Generated on Sat Feb  2 17:06:57 2013 by
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.8.3 (ruby-1.9.3).
</div>

  </body>
</html>