This commit is contained in:
Christian Mehlmauer
2013-01-27 01:16:44 +01:00
parent 60a6f16ddd
commit 1afe12657f
38 changed files with 3644 additions and 437 deletions

View File

@@ -260,19 +260,23 @@
<div class="method-description">
<p>The serializer must have the 2 methods .load and .dump (Marshal and YAML
have them) YAML is Human Readable, contrary to Marshal which store in a
binary format Marshal does not need any “require”</p>
<p>The serializer must have the 2 methods .load and .dump</p>
<pre>(Marshal and YAML have them)</pre>
<p>YAML is Human Readable, contrary to Marshal which store in a binary format
Marshal does not need any “require”</p>
<div class="method-source-code" id="new-source">
<pre><span class="ruby-comment"># File lib/cache_file_store.rb, line 34</span>
<pre><span class="ruby-comment"># File lib/cache_file_store.rb, line 36</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">storage_path</span>, <span class="ruby-identifier">serializer</span> = <span class="ruby-constant">Marshal</span>)
<span class="ruby-ivar">@storage_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">storage_path</span>)
<span class="ruby-ivar">@serializer</span> = <span class="ruby-identifier">serializer</span>
<span class="ruby-comment"># File.directory? for ruby &lt;= 1.9 otherwise, it makes more sense to do Dir.exist? :/</span>
<span class="ruby-comment"># File.directory? for ruby &lt;= 1.9 otherwise,</span>
<span class="ruby-comment"># it makes more sense to do Dir.exist? :/</span>
<span class="ruby-keyword">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-ivar">@storage_path</span>)
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-ivar">@storage_path</span>)
<span class="ruby-keyword">end</span>
@@ -309,7 +313,7 @@ binary format Marshal does not need any “require”</p>
<div class="method-source-code" id="clean-source">
<pre><span class="ruby-comment"># File lib/cache_file_store.rb, line 44</span>
<pre><span class="ruby-comment"># File lib/cache_file_store.rb, line 47</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">clean</span>
<span class="ruby-constant">Dir</span>[<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@storage_path</span>, <span class="ruby-string">'*'</span>)].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">f</span>)
@@ -341,7 +345,7 @@ binary format Marshal does not need any “require”</p>
<div class="method-source-code" id="get_entry_file_path-source">
<pre><span class="ruby-comment"># File lib/cache_file_store.rb, line 66</span>
<pre><span class="ruby-comment"># File lib/cache_file_store.rb, line 69</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">get_entry_file_path</span>(<span class="ruby-identifier">key</span>)
<span class="ruby-ivar">@storage_path</span> <span class="ruby-operator">+</span> <span class="ruby-string">'/'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">key</span>
<span class="ruby-keyword">end</span></pre>
@@ -371,7 +375,7 @@ binary format Marshal does not need any “require”</p>
<div class="method-source-code" id="read_entry-source">
<pre><span class="ruby-comment"># File lib/cache_file_store.rb, line 50</span>
<pre><span class="ruby-comment"># File lib/cache_file_store.rb, line 53</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">read_entry</span>(<span class="ruby-identifier">key</span>)
<span class="ruby-identifier">entry_file_path</span> = <span class="ruby-identifier">get_entry_file_path</span>(<span class="ruby-identifier">key</span>)
@@ -405,7 +409,7 @@ binary format Marshal does not need any “require”</p>
<div class="method-source-code" id="write_entry-source">
<pre><span class="ruby-comment"># File lib/cache_file_store.rb, line 58</span>
<pre><span class="ruby-comment"># File lib/cache_file_store.rb, line 61</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">write_entry</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">data_to_store</span>, <span class="ruby-identifier">cache_timeout</span>)
<span class="ruby-keyword">if</span> <span class="ruby-identifier">cache_timeout</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">get_entry_file_path</span>(<span class="ruby-identifier">key</span>), <span class="ruby-string">'w'</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>