mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
321 lines
9.5 KiB
HTML
321 lines
9.5 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: BulkCacheFetcher
|
|
|
|
— Documentation by YARD 0.8.7.6
|
|
|
|
</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#!BulkCacheFetcher.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> »
|
|
|
|
|
|
<span class="title">BulkCacheFetcher</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: BulkCacheFetcher
|
|
|
|
|
|
|
|
</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">BulkCacheFetcher</li>
|
|
|
|
</ul>
|
|
<a href="#" class="inheritanceTree">show all</a>
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<dt class="r2 last">Defined in:</dt>
|
|
<dd class="r2 last">lib/bulk_cache_fetcher.rb</dd>
|
|
|
|
</dl>
|
|
<div class="clear"></div>
|
|
|
|
<h2>Overview</h2><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
<p><a
|
|
href="https://github.com/justinweiss/bulk_cache_fetcher/blob/df1c83e06b9641b7ec3408ec577b37528021190f/lib/bulk_cache_fetcher.rb">github.com/justinweiss/bulk_cache_fetcher/blob/df1c83e06b9641b7ec3408ec577b37528021190f/lib/bulk_cache_fetcher.rb</a>
|
|
Fetches many objects from a cache in order. In the event that some objects
|
|
can't be served from the cache, you will have the opportunity to fetch
|
|
them in bulk. This allows you to preload and cache entire object
|
|
hierarchies, which works particularly well with Rails' nested caching
|
|
while avoiding the n+1 queries problem in the uncached case.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
|
|
</div>
|
|
<h2>Constant Summary</h2>
|
|
|
|
<dl class="constants">
|
|
|
|
<dt id="VERSION-constant" class="">VERSION =
|
|
|
|
</dt>
|
|
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>1.0.0</span><span class='tstring_end'>'</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
|
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<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="#fetch-instance_method" title="#fetch (instance method)">- (Object) <strong>fetch</strong>(object_identifiers, options = {}, &finder_block) </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'>
|
|
<p>Returns a list of objects identified by object_identifiers.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#initialize-instance_method" title="#initialize (instance method)">- (BulkCacheFetcher) <strong>initialize</strong>(cache) </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<span class="note title constructor">constructor</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'>
|
|
<p>Creates a new bulk cache fetcher, backed by <code>cache</code>.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
<div id="constructor_details" class="method_details_list">
|
|
<h2>Constructor Details</h2>
|
|
|
|
<div class="method_details first">
|
|
<h3 class="signature first" id="initialize-instance_method">
|
|
|
|
- (<tt><span class='object_link'><a href="" title="BulkCacheFetcher (class)">BulkCacheFetcher</a></span></tt>) <strong>initialize</strong>(cache)
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
<p>Creates a new bulk cache fetcher, backed by <code>cache</code>. Cache must
|
|
respond to the standard Rails cache API, described on <a
|
|
href="http://guides.rubyonrails.org/caching_with_rails.html">guides.rubyonrails.org/caching_with_rails.html</a></p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
14
|
|
15
|
|
16</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/bulk_cache_fetcher.rb', line 14</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_cache'>cache</span><span class='rparen'>)</span>
|
|
<span class='ivar'>@cache</span> <span class='op'>=</span> <span class='id identifier rubyid_cache'>cache</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
<div id="instance_method_details" class="method_details_list">
|
|
<h2>Instance Method Details</h2>
|
|
|
|
|
|
<div class="method_details first">
|
|
<h3 class="signature first" id="fetch-instance_method">
|
|
|
|
- (<tt>Object</tt>) <strong>fetch</strong>(object_identifiers, options = {}, &finder_block)
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
<p>Returns a list of objects identified by <code>object_identifiers</code>.
|
|
<code>fetch</code> will try to find the objects from the cache first.
|
|
Identifiers for objects that aren't in the cache will be passed as an
|
|
ordered list to <code>finder_block</code>, where you can find the objects
|
|
as you see fit. These objects should be returned in the same order as the
|
|
identifiers that were passed into the block, because they'll be cached
|
|
under their respective keys. The objects returned by <code>fetch</code>
|
|
will be returned in the same order as the <code>object_identifiers</code>
|
|
passed in.</p>
|
|
|
|
<p><code>options</code> will be passed along unmodified when caching newly
|
|
found objects, so you can use it for things like setting cache expiration.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
31
|
|
32
|
|
33
|
|
34
|
|
35
|
|
36</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/bulk_cache_fetcher.rb', line 31</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_object_identifiers'>object_identifiers</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='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_finder_block'>finder_block</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_object_identifiers'>object_identifiers</span> <span class='op'>=</span> <span class='id identifier rubyid_normalize'>normalize</span><span class='lparen'>(</span><span class='id identifier rubyid_object_identifiers'>object_identifiers</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_cached_keys_with_objects'>cached_keys_with_objects</span><span class='comma'>,</span> <span class='id identifier rubyid_uncached_identifiers'>uncached_identifiers</span> <span class='op'>=</span> <span class='id identifier rubyid_partition'>partition</span><span class='lparen'>(</span><span class='id identifier rubyid_object_identifiers'>object_identifiers</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_found_objects'>found_objects</span> <span class='op'>=</span> <span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='id identifier rubyid_uncached_identifiers'>uncached_identifiers</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_finder_block'>finder_block</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_coalesce'>coalesce</span><span class='lparen'>(</span><span class='id identifier rubyid_cache_keys'>cache_keys</span><span class='lparen'>(</span><span class='id identifier rubyid_object_identifiers'>object_identifiers</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_cached_keys_with_objects'>cached_keys_with_objects</span><span class='comma'>,</span> <span class='id identifier rubyid_found_objects'>found_objects</span><span class='rparen'>)</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="footer">
|
|
Generated on Thu Jun 16 09:05:10 2016 by
|
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
0.8.7.6 (ruby-2.2.4).
|
|
</div>
|
|
|
|
</body>
|
|
</html> |