sass-site/source/documentation/Sass/CacheStores/Base.html
2018-10-22 14:13:05 -07:00

827 lines
24 KiB
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: Sass::CacheStores::Base
&mdash; Documentation by YARD 0.9.12
</title>
<link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="../../../assets/css/docs.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#!Sass/CacheStores/Base.html";
</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 (B)</a> &raquo;
<span class='title'><span class='object_link'><a href="../../Sass.html" title="Sass (module)">Sass</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../CacheStores.html" title="Sass::CacheStores (module)">CacheStores</a></span></span>
&raquo;
<span class="title">Base</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: Sass::CacheStores::Base
<span class="abstract note title">Abstract</span>
</h1>
<dl class="box">
<dt class="r1">Inherits:</dt>
<dd class="r1">
<span class="inheritName">Object</span>
<ul class="fullTree">
<li>Object</li>
<li class="next">Sass::CacheStores::Base</li>
</ul>
<a href="#" class="inheritanceTree">show all</a>
</dd>
<dt class="r2 last">Defined in:</dt>
<dd class="r2 last">.ruby-sass/lib/sass/cache_stores/base.rb</dd>
</dl>
<div class="clear"></div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<div class="note abstract">
<strong>This class is abstract.</strong>
<div class='inline'></div>
</div>
<p>An abstract base class for backends for the Sass cache. Any key-value store
can act as such a backend; it just needs to implement the <span class='object_link'><a href="#_store-instance_method" title="Sass::CacheStores::Base#_store (method)">#_store</a></span> and
<span class='object_link'><a href="#_retrieve-instance_method" title="Sass::CacheStores::Base#_retrieve (method)">#_retrieve</a></span> methods.</p>
<p>To use a cache store with Sass, use the
<a href="../../file.SASS_REFERENCE.html#cache_store-option" title="`:cache_store` option">`:cache_store` option</a>.</p>
</div>
</div>
<div class="tags">
</div><div id="subclasses">
<h2>Direct Known Subclasses</h2>
<p class="children"><span class='object_link'><a href="Chain.html" title="Sass::CacheStores::Chain (class)">Chain</a></span>, <span class='object_link'><a href="Filesystem.html" title="Sass::CacheStores::Filesystem (class)">Filesystem</a></span>, <span class='object_link'><a href="Memory.html" title="Sass::CacheStores::Memory (class)">Memory</a></span>, <span class='object_link'><a href="Null.html" title="Sass::CacheStores::Null (class)">Null</a></span></p>
</div>
<div id="subclasses">
<h2>Direct Known Subclasses</h2>
<p class="children"><span class='object_link'><a href="Chain.html" title="Sass::CacheStores::Chain (class)">Chain</a></span>, <span class='object_link'><a href="Filesystem.html" title="Sass::CacheStores::Filesystem (class)">Filesystem</a></span>, <span class='object_link'><a href="Memory.html" title="Sass::CacheStores::Memory (class)">Memory</a></span>, <span class='object_link'><a href="Null.html" title="Sass::CacheStores::Null (class)">Null</a></span></p>
</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="#_retrieve-instance_method" title="#_retrieve (instance method)">#<strong>_retrieve</strong>(key, version, sha) &#x21d2; String, NilClass </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Retrieved cached contents.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#_store-instance_method" title="#_store (instance method)">#<strong>_store</strong>(key, version, sha, contents) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Store cached contents for later retrieval Must be implemented by all
CacheStore subclasses.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#key-instance_method" title="#key (instance method)">#<strong>key</strong>(sass_dirname, sass_basename) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Return the key for the sass file.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#retrieve-instance_method" title="#retrieve (instance method)">#<strong>retrieve</strong>(key, sha) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Retrieve a <span class='object_link'><a href="../Tree/RootNode.html" title="Sass::Tree::RootNode (class)">Tree::RootNode</a></span>.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#store-instance_method" title="#store (instance method)">#<strong>store</strong>(key, sha, root) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Store a <span class='object_link'><a href="../Tree/RootNode.html" title="Sass::Tree::RootNode (class)">Tree::RootNode</a></span>.</p>
</div></span>
</li>
</ul>
<div id="instance_method_details" class="method_details_list">
<h2>Instance Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="_retrieve-instance_method">
#<strong>_retrieve</strong>(key, version, sha) &#x21d2; <tt>String</tt>, <tt>NilClass</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Retrieved cached contents. Must be implemented by all subclasses.</p>
<p>Note: if the key exists but the sha or version have changed, then the key
may be deleted by the cache store, if it wants to do so.</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>
&mdash;
<div class='inline'>
<p>The key to retrieve</p>
</div>
</li>
<li>
<span class='name'>version</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The current sass version. Cached contents must not be retrieved across
different versions of sass.</p>
</div>
</li>
<li>
<span class='name'>sha</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The sha of the sass source. Cached contents must not be retrieved if the
sha has changed.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The contents that were previously stored.</p>
</div>
</li>
<li>
<span class='type'>(<tt>NilClass</tt>)</span>
&mdash;
<div class='inline'>
<p>when the cache key is not found or the version or sha have changed.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
41
42
43</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '.ruby-sass/lib/sass/cache_stores/base.rb', line 41</span>
<span class='kw'>def</span> <span class='id identifier rubyid__retrieve'>_retrieve</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_version'>version</span><span class='comma'>,</span> <span class='id identifier rubyid_sha'>sha</span><span class='rparen'>)</span>
<span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='embexpr_end'>}</span><span class='tstring_content'> must implement #_retrieve.</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="_store-instance_method">
#<strong>_store</strong>(key, version, sha, contents) &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Store cached contents for later retrieval Must be implemented by all
CacheStore subclasses</p>
<p>Note: cache contents contain binary data.</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>
&mdash;
<div class='inline'>
<p>The key to store the contents under</p>
</div>
</li>
<li>
<span class='name'>version</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The current sass version. Cached contents must not be retrieved across
different versions of sass.</p>
</div>
</li>
<li>
<span class='name'>sha</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The sha of the sass source. Cached contents must not be retrieved if the
sha has changed.</p>
</div>
</li>
<li>
<span class='name'>contents</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The contents to store.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
24
25
26</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '.ruby-sass/lib/sass/cache_stores/base.rb', line 24</span>
<span class='kw'>def</span> <span class='id identifier rubyid__store'>_store</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_version'>version</span><span class='comma'>,</span> <span class='id identifier rubyid_sha'>sha</span><span class='comma'>,</span> <span class='id identifier rubyid_contents'>contents</span><span class='rparen'>)</span>
<span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='embexpr_end'>}</span><span class='tstring_content'> must implement #_store.</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="key-instance_method">
#<strong>key</strong>(sass_dirname, sass_basename) &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Return the key for the sass file.</p>
<p>The `(sass_dirname, sass_basename)` pair should uniquely identify the Sass
document, but otherwise there are no restrictions on their content.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>sass_dirname</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The fully-expanded location of the Sass file. This corresponds to the
directory name on a filesystem.</p>
</div>
</li>
<li>
<span class='name'>sass_basename</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The name of the Sass file that is being referenced. This corresponds to the
basename on a filesystem.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
81
82
83
84
85</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '.ruby-sass/lib/sass/cache_stores/base.rb', line 81</span>
<span class='kw'>def</span> <span class='id identifier rubyid_key'>key</span><span class='lparen'>(</span><span class='id identifier rubyid_sass_dirname'>sass_dirname</span><span class='comma'>,</span> <span class='id identifier rubyid_sass_basename'>sass_basename</span><span class='rparen'>)</span>
<span class='id identifier rubyid_dir'>dir</span> <span class='op'>=</span> <span class='const'>Digest</span><span class='op'>::</span><span class='const'>SHA1</span><span class='period'>.</span><span class='id identifier rubyid_hexdigest'>hexdigest</span><span class='lparen'>(</span><span class='id identifier rubyid_sass_dirname'>sass_dirname</span><span class='rparen'>)</span>
<span class='id identifier rubyid_filename'>filename</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_sass_basename'>sass_basename</span><span class='embexpr_end'>}</span><span class='tstring_content'>c</span><span class='tstring_end'>&quot;</span></span>
<span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_dir'>dir</span><span class='embexpr_end'>}</span><span class='tstring_content'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_filename'>filename</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="retrieve-instance_method">
#<strong>retrieve</strong>(key, sha) &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Retrieve a <span class='object_link'><a href="../Tree/RootNode.html" title="Sass::Tree::RootNode (class)">Tree::RootNode</a></span>.</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>
&mdash;
<div class='inline'>
<p>The key the root element was stored under.</p>
</div>
</li>
<li>
<span class='name'>sha</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The checksum of the root element&#39;s content.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Object</tt>)</span>
&mdash;
<div class='inline'>
<p>The cached object.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
62
63
64
65
66
67
68</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '.ruby-sass/lib/sass/cache_stores/base.rb', line 62</span>
<span class='kw'>def</span> <span class='id identifier rubyid_retrieve'>retrieve</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_sha'>sha</span><span class='rparen'>)</span>
<span class='id identifier rubyid_contents'>contents</span> <span class='op'>=</span> <span class='id identifier rubyid__retrieve'>_retrieve</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="../../Sass.html" title="Sass (module)">Sass</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Sass.html#VERSION-constant" title="Sass::VERSION (constant)">VERSION</a></span></span><span class='comma'>,</span> <span class='id identifier rubyid_sha'>sha</span><span class='rparen'>)</span>
<span class='const'>Marshal</span><span class='period'>.</span><span class='id identifier rubyid_load'>load</span><span class='lparen'>(</span><span class='id identifier rubyid_contents'>contents</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_contents'>contents</span>
<span class='kw'>rescue</span> <span class='const'>EOFError</span><span class='comma'>,</span> <span class='const'>TypeError</span><span class='comma'>,</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='const'>LoadError</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='const'><span class='object_link'><a href="../../Sass.html" title="Sass (module)">Sass</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Util.html" title="Sass::Util (module)">Util</a></span></span><span class='period'>.</span><span class='id identifier rubyid_sass_warn'><span class='object_link'><a href="../Util.html#sass_warn-instance_method" title="Sass::Util#sass_warn (method)">sass_warn</a></span></span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Warning. Error encountered while reading cache </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_path_to'>path_to</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_e'>e</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>nil</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="store-instance_method">
#<strong>store</strong>(key, sha, root) &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Store a <span class='object_link'><a href="../Tree/RootNode.html" title="Sass::Tree::RootNode (class)">Tree::RootNode</a></span>.</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>
&mdash;
<div class='inline'>
<p>The key to store it under.</p>
</div>
</li>
<li>
<span class='name'>sha</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The checksum for the contents that are being stored.</p>
</div>
</li>
<li>
<span class='name'>root</span>
<span class='type'>(<tt>Object</tt>)</span>
&mdash;
<div class='inline'>
<p>The root node to cache.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
50
51
52
53
54
55</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '.ruby-sass/lib/sass/cache_stores/base.rb', line 50</span>
<span class='kw'>def</span> <span class='id identifier rubyid_store'>store</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_sha'>sha</span><span class='comma'>,</span> <span class='id identifier rubyid_root'><span class='object_link'><a href="../../top-level-namespace.html" title="Top Level Namespace (root)">root</a></span></span><span class='rparen'>)</span>
<span class='id identifier rubyid__store'>_store</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="../../Sass.html" title="Sass (module)">Sass</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Sass.html#VERSION-constant" title="Sass::VERSION (constant)">VERSION</a></span></span><span class='comma'>,</span> <span class='id identifier rubyid_sha'>sha</span><span class='comma'>,</span> <span class='const'>Marshal</span><span class='period'>.</span><span class='id identifier rubyid_dump'>dump</span><span class='lparen'>(</span><span class='id identifier rubyid_root'><span class='object_link'><a href="../../top-level-namespace.html" title="Top Level Namespace (root)">root</a></span></span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='kw'>rescue</span> <span class='const'>TypeError</span><span class='comma'>,</span> <span class='const'>LoadError</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='const'><span class='object_link'><a href="../../Sass.html" title="Sass (module)">Sass</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Util.html" title="Sass::Util (module)">Util</a></span></span><span class='period'>.</span><span class='id identifier rubyid_sass_warn'><span class='object_link'><a href="../Util.html#sass_warn-instance_method" title="Sass::Util#sass_warn (method)">sass_warn</a></span></span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Warning. Error encountered while saving cache </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_path_to'>path_to</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_e'>e</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>nil</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Mon Oct 22 13:20:50 2018 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.12 (ruby-2.5.3).
</div>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-535380-14', 'sass-lang.com');
ga('send', 'pageview');
</script>
</body>
</html>