api_wrapper 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rubocop.yml +7 -0
- data/CHANGELOG.md +18 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +22 -0
- data/LICENSE.txt +21 -0
- data/README.md +153 -0
- data/Rakefile +31 -0
- data/api_wrapper.gemspec +34 -0
- data/doc/ApiWrapper/ApiManager.html +807 -0
- data/doc/ApiWrapper/Cache/CachePolicy.html +907 -0
- data/doc/ApiWrapper/Cache/CacheStore.html +674 -0
- data/doc/ApiWrapper/Cache.html +117 -0
- data/doc/ApiWrapper/Configuration.html +366 -0
- data/doc/ApiWrapper/HttpClient/BaseClient.html +349 -0
- data/doc/ApiWrapper/HttpClient/FaradayClient.html +299 -0
- data/doc/ApiWrapper/HttpClient.html +117 -0
- data/doc/ApiWrapper.html +543 -0
- data/doc/_index.html +195 -0
- data/doc/class_list.html +54 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +503 -0
- data/doc/file.README.html +248 -0
- data/doc/file_list.html +59 -0
- data/doc/frames.html +22 -0
- data/doc/index.html +248 -0
- data/doc/js/app.js +344 -0
- data/doc/js/full_list.js +242 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +286 -0
- data/doc/top-level-namespace.html +110 -0
- data/lib/api_wrapper/api_manager.rb +86 -0
- data/lib/api_wrapper/cache/README.md +78 -0
- data/lib/api_wrapper/cache/cache_policy.rb +115 -0
- data/lib/api_wrapper/cache/cache_store.rb +84 -0
- data/lib/api_wrapper/cache/redis_cache_store.rb +3 -0
- data/lib/api_wrapper/http_client/base_client.rb +26 -0
- data/lib/api_wrapper/http_client/faraday_client.rb +81 -0
- data/lib/api_wrapper/version.rb +5 -0
- data/lib/api_wrapper.rb +83 -0
- metadata +121 -0
@@ -0,0 +1,907 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: ApiWrapper::Cache::CachePolicy
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.37
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" />
|
16
|
+
|
17
|
+
<script type="text/javascript">
|
18
|
+
pathId = "ApiWrapper::Cache::CachePolicy";
|
19
|
+
relpath = '../../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../../_index.html">Index (C)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../../ApiWrapper.html" title="ApiWrapper (module)">ApiWrapper</a></span></span> » <span class='title'><span class='object_link'><a href="../Cache.html" title="ApiWrapper::Cache (module)">Cache</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">CachePolicy</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: ApiWrapper::Cache::CachePolicy
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName">Object</span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next">ApiWrapper::Cache::CachePolicy</li>
|
78
|
+
|
79
|
+
</ul>
|
80
|
+
<a href="#" class="inheritanceTree">show all</a>
|
81
|
+
|
82
|
+
</dd>
|
83
|
+
</dl>
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<dl>
|
96
|
+
<dt>Defined in:</dt>
|
97
|
+
<dd>lib/api_wrapper/cache/cache_policy.rb</dd>
|
98
|
+
</dl>
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<h2>Overview</h2><div class="docstring">
|
103
|
+
<div class="discussion">
|
104
|
+
|
105
|
+
<p>CachePolicy manages caching behavior, including cache storage and time-to-live (TTL) settings.</p>
|
106
|
+
|
107
|
+
<p>It allows setting global TTLs, custom TTLs for specific endpoints, and controlling which endpoints should not use the cache.</p>
|
108
|
+
|
109
|
+
|
110
|
+
</div>
|
111
|
+
</div>
|
112
|
+
<div class="tags">
|
113
|
+
|
114
|
+
|
115
|
+
</div>
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
|
120
|
+
<ul class="summary">
|
121
|
+
|
122
|
+
<li class="public ">
|
123
|
+
<span class="summary_signature">
|
124
|
+
|
125
|
+
<a href="#cache_store-instance_method" title="#cache_store (instance method)">#<strong>cache_store</strong> ⇒ CacheStore </a>
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
</span>
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
<span class="note title readonly">readonly</span>
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
<span class="summary_desc"><div class='inline'>
|
145
|
+
<p>The cache store used for storing cached data.</p>
|
146
|
+
</div></span>
|
147
|
+
|
148
|
+
</li>
|
149
|
+
|
150
|
+
|
151
|
+
</ul>
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
<h2>
|
158
|
+
Instance Method Summary
|
159
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
160
|
+
</h2>
|
161
|
+
|
162
|
+
<ul class="summary">
|
163
|
+
|
164
|
+
<li class="public ">
|
165
|
+
<span class="summary_signature">
|
166
|
+
|
167
|
+
<a href="#add_custom_ttl-instance_method" title="#add_custom_ttl (instance method)">#<strong>add_custom_ttl</strong>(endpoint, ttl = 300) ⇒ Object </a>
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
</span>
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
<span class="summary_desc"><div class='inline'>
|
182
|
+
<p>Adds a custom TTL for a specific endpoint.</p>
|
183
|
+
</div></span>
|
184
|
+
|
185
|
+
</li>
|
186
|
+
|
187
|
+
|
188
|
+
<li class="public ">
|
189
|
+
<span class="summary_signature">
|
190
|
+
|
191
|
+
<a href="#add_no_cache_endpoint-instance_method" title="#add_no_cache_endpoint (instance method)">#<strong>add_no_cache_endpoint</strong>(endpoint) ⇒ Object </a>
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
</span>
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
<span class="summary_desc"><div class='inline'>
|
206
|
+
<p>Adds an endpoint that should bypass the cache.</p>
|
207
|
+
</div></span>
|
208
|
+
|
209
|
+
</li>
|
210
|
+
|
211
|
+
|
212
|
+
<li class="public ">
|
213
|
+
<span class="summary_signature">
|
214
|
+
|
215
|
+
<a href="#fetch-instance_method" title="#fetch (instance method)">#<strong>fetch</strong>(endpoint, force_refresh: false) { ... } ⇒ Object </a>
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
</span>
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
<span class="summary_desc"><div class='inline'>
|
230
|
+
<p>Fetches the data for the given endpoint, using cache if applicable.</p>
|
231
|
+
</div></span>
|
232
|
+
|
233
|
+
</li>
|
234
|
+
|
235
|
+
|
236
|
+
<li class="public ">
|
237
|
+
<span class="summary_signature">
|
238
|
+
|
239
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(cache_store, global_ttl = 300) ⇒ CachePolicy </a>
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
</span>
|
244
|
+
|
245
|
+
|
246
|
+
<span class="note title constructor">constructor</span>
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
<span class="summary_desc"><div class='inline'>
|
256
|
+
<p>Initializes the CachePolicy with a cache store and global TTL.</p>
|
257
|
+
</div></span>
|
258
|
+
|
259
|
+
</li>
|
260
|
+
|
261
|
+
|
262
|
+
<li class="public ">
|
263
|
+
<span class="summary_signature">
|
264
|
+
|
265
|
+
<a href="#ttl_for-instance_method" title="#ttl_for (instance method)">#<strong>ttl_for</strong>(endpoint) ⇒ Integer </a>
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
</span>
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
<span class="summary_desc"><div class='inline'>
|
280
|
+
<p>Returns the TTL for a specific endpoint.</p>
|
281
|
+
</div></span>
|
282
|
+
|
283
|
+
</li>
|
284
|
+
|
285
|
+
|
286
|
+
<li class="public ">
|
287
|
+
<span class="summary_signature">
|
288
|
+
|
289
|
+
<a href="#use_cache%3F-instance_method" title="#use_cache? (instance method)">#<strong>use_cache?</strong>(endpoint) ⇒ Boolean </a>
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
</span>
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
<span class="summary_desc"><div class='inline'>
|
304
|
+
<p>Determines if caching should be used for the given endpoint.</p>
|
305
|
+
</div></span>
|
306
|
+
|
307
|
+
</li>
|
308
|
+
|
309
|
+
|
310
|
+
</ul>
|
311
|
+
|
312
|
+
|
313
|
+
<div id="constructor_details" class="method_details_list">
|
314
|
+
<h2>Constructor Details</h2>
|
315
|
+
|
316
|
+
<div class="method_details first">
|
317
|
+
<h3 class="signature first" id="initialize-instance_method">
|
318
|
+
|
319
|
+
#<strong>initialize</strong>(cache_store, global_ttl = 300) ⇒ <tt><span class='object_link'><a href="" title="ApiWrapper::Cache::CachePolicy (class)">CachePolicy</a></span></tt>
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
</h3><div class="docstring">
|
326
|
+
<div class="discussion">
|
327
|
+
|
328
|
+
<p>Initializes the CachePolicy with a cache store and global TTL.</p>
|
329
|
+
|
330
|
+
|
331
|
+
</div>
|
332
|
+
</div>
|
333
|
+
<div class="tags">
|
334
|
+
<p class="tag_title">Parameters:</p>
|
335
|
+
<ul class="param">
|
336
|
+
|
337
|
+
<li>
|
338
|
+
|
339
|
+
<span class='name'>cache_store</span>
|
340
|
+
|
341
|
+
|
342
|
+
<span class='type'>(<tt><span class='object_link'><a href="CacheStore.html" title="ApiWrapper::Cache::CacheStore (class)">CacheStore</a></span></tt>, <tt>RedisCacheStore</tt>)</span>
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
—
|
347
|
+
<div class='inline'>
|
348
|
+
<p>The cache store to use for caching.</p>
|
349
|
+
</div>
|
350
|
+
|
351
|
+
</li>
|
352
|
+
|
353
|
+
<li>
|
354
|
+
|
355
|
+
<span class='name'>global_ttl</span>
|
356
|
+
|
357
|
+
|
358
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
359
|
+
|
360
|
+
|
361
|
+
<em class="default">(defaults to: <tt>300</tt>)</em>
|
362
|
+
|
363
|
+
|
364
|
+
—
|
365
|
+
<div class='inline'>
|
366
|
+
<p>The default TTL (in seconds) for caching.</p>
|
367
|
+
</div>
|
368
|
+
|
369
|
+
</li>
|
370
|
+
|
371
|
+
</ul>
|
372
|
+
|
373
|
+
|
374
|
+
</div><table class="source_code">
|
375
|
+
<tr>
|
376
|
+
<td>
|
377
|
+
<pre class="lines">
|
378
|
+
|
379
|
+
|
380
|
+
18
|
381
|
+
19
|
382
|
+
20
|
383
|
+
21
|
384
|
+
22
|
385
|
+
23</pre>
|
386
|
+
</td>
|
387
|
+
<td>
|
388
|
+
<pre class="code"><span class="info file"># File 'lib/api_wrapper/cache/cache_policy.rb', line 18</span>
|
389
|
+
|
390
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_cache_store'>cache_store</span><span class='comma'>,</span> <span class='id identifier rubyid_global_ttl'>global_ttl</span> <span class='op'>=</span> <span class='int'>300</span><span class='rparen'>)</span>
|
391
|
+
<span class='ivar'>@cache_store</span> <span class='op'>=</span> <span class='id identifier rubyid_cache_store'>cache_store</span>
|
392
|
+
<span class='ivar'>@global_ttl</span> <span class='op'>=</span> <span class='id identifier rubyid_global_ttl'>global_ttl</span>
|
393
|
+
<span class='ivar'>@custom_ttls</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
394
|
+
<span class='ivar'>@no_cache_endpoints</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
395
|
+
<span class='kw'>end</span></pre>
|
396
|
+
</td>
|
397
|
+
</tr>
|
398
|
+
</table>
|
399
|
+
</div>
|
400
|
+
|
401
|
+
</div>
|
402
|
+
|
403
|
+
<div id="instance_attr_details" class="attr_details">
|
404
|
+
<h2>Instance Attribute Details</h2>
|
405
|
+
|
406
|
+
|
407
|
+
<span id=""></span>
|
408
|
+
<div class="method_details first">
|
409
|
+
<h3 class="signature first" id="cache_store-instance_method">
|
410
|
+
|
411
|
+
#<strong>cache_store</strong> ⇒ <tt><span class='object_link'><a href="CacheStore.html" title="ApiWrapper::Cache::CacheStore (class)">CacheStore</a></span></tt> <span class="extras">(readonly)</span>
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
</h3><div class="docstring">
|
418
|
+
<div class="discussion">
|
419
|
+
|
420
|
+
<p>The cache store used for storing cached data.</p>
|
421
|
+
|
422
|
+
|
423
|
+
</div>
|
424
|
+
</div>
|
425
|
+
<div class="tags">
|
426
|
+
|
427
|
+
<p class="tag_title">Returns:</p>
|
428
|
+
<ul class="return">
|
429
|
+
|
430
|
+
<li>
|
431
|
+
|
432
|
+
|
433
|
+
<span class='type'>(<tt><span class='object_link'><a href="CacheStore.html" title="ApiWrapper::Cache::CacheStore (class)">CacheStore</a></span></tt>)</span>
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
—
|
438
|
+
<div class='inline'>
|
439
|
+
<p>the current value of cache_store</p>
|
440
|
+
</div>
|
441
|
+
|
442
|
+
</li>
|
443
|
+
|
444
|
+
</ul>
|
445
|
+
|
446
|
+
</div><table class="source_code">
|
447
|
+
<tr>
|
448
|
+
<td>
|
449
|
+
<pre class="lines">
|
450
|
+
|
451
|
+
|
452
|
+
11
|
453
|
+
12
|
454
|
+
13</pre>
|
455
|
+
</td>
|
456
|
+
<td>
|
457
|
+
<pre class="code"><span class="info file"># File 'lib/api_wrapper/cache/cache_policy.rb', line 11</span>
|
458
|
+
|
459
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_cache_store'>cache_store</span>
|
460
|
+
<span class='ivar'>@cache_store</span>
|
461
|
+
<span class='kw'>end</span></pre>
|
462
|
+
</td>
|
463
|
+
</tr>
|
464
|
+
</table>
|
465
|
+
</div>
|
466
|
+
|
467
|
+
</div>
|
468
|
+
|
469
|
+
|
470
|
+
<div id="instance_method_details" class="method_details_list">
|
471
|
+
<h2>Instance Method Details</h2>
|
472
|
+
|
473
|
+
|
474
|
+
<div class="method_details first">
|
475
|
+
<h3 class="signature first" id="add_custom_ttl-instance_method">
|
476
|
+
|
477
|
+
#<strong>add_custom_ttl</strong>(endpoint, ttl = 300) ⇒ <tt>Object</tt>
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
</h3><div class="docstring">
|
484
|
+
<div class="discussion">
|
485
|
+
|
486
|
+
<p>Adds a custom TTL for a specific endpoint.</p>
|
487
|
+
|
488
|
+
|
489
|
+
</div>
|
490
|
+
</div>
|
491
|
+
<div class="tags">
|
492
|
+
<p class="tag_title">Parameters:</p>
|
493
|
+
<ul class="param">
|
494
|
+
|
495
|
+
<li>
|
496
|
+
|
497
|
+
<span class='name'>endpoint</span>
|
498
|
+
|
499
|
+
|
500
|
+
<span class='type'>(<tt>String</tt>)</span>
|
501
|
+
|
502
|
+
|
503
|
+
|
504
|
+
—
|
505
|
+
<div class='inline'>
|
506
|
+
<p>The endpoint to apply a custom TTL to.</p>
|
507
|
+
</div>
|
508
|
+
|
509
|
+
</li>
|
510
|
+
|
511
|
+
<li>
|
512
|
+
|
513
|
+
<span class='name'>ttl</span>
|
514
|
+
|
515
|
+
|
516
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
517
|
+
|
518
|
+
|
519
|
+
<em class="default">(defaults to: <tt>300</tt>)</em>
|
520
|
+
|
521
|
+
|
522
|
+
—
|
523
|
+
<div class='inline'>
|
524
|
+
<p>The custom TTL value in seconds.</p>
|
525
|
+
</div>
|
526
|
+
|
527
|
+
</li>
|
528
|
+
|
529
|
+
</ul>
|
530
|
+
|
531
|
+
|
532
|
+
</div><table class="source_code">
|
533
|
+
<tr>
|
534
|
+
<td>
|
535
|
+
<pre class="lines">
|
536
|
+
|
537
|
+
|
538
|
+
36
|
539
|
+
37
|
540
|
+
38</pre>
|
541
|
+
</td>
|
542
|
+
<td>
|
543
|
+
<pre class="code"><span class="info file"># File 'lib/api_wrapper/cache/cache_policy.rb', line 36</span>
|
544
|
+
|
545
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_add_custom_ttl'>add_custom_ttl</span><span class='lparen'>(</span><span class='id identifier rubyid_endpoint'>endpoint</span><span class='comma'>,</span> <span class='id identifier rubyid_ttl'>ttl</span> <span class='op'>=</span> <span class='int'>300</span><span class='rparen'>)</span>
|
546
|
+
<span class='ivar'>@custom_ttls</span><span class='lbracket'>[</span><span class='id identifier rubyid_endpoint'>endpoint</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_ttl'>ttl</span>
|
547
|
+
<span class='kw'>end</span></pre>
|
548
|
+
</td>
|
549
|
+
</tr>
|
550
|
+
</table>
|
551
|
+
</div>
|
552
|
+
|
553
|
+
<div class="method_details ">
|
554
|
+
<h3 class="signature " id="add_no_cache_endpoint-instance_method">
|
555
|
+
|
556
|
+
#<strong>add_no_cache_endpoint</strong>(endpoint) ⇒ <tt>Object</tt>
|
557
|
+
|
558
|
+
|
559
|
+
|
560
|
+
|
561
|
+
|
562
|
+
</h3><div class="docstring">
|
563
|
+
<div class="discussion">
|
564
|
+
|
565
|
+
<p>Adds an endpoint that should bypass the cache.</p>
|
566
|
+
|
567
|
+
|
568
|
+
</div>
|
569
|
+
</div>
|
570
|
+
<div class="tags">
|
571
|
+
<p class="tag_title">Parameters:</p>
|
572
|
+
<ul class="param">
|
573
|
+
|
574
|
+
<li>
|
575
|
+
|
576
|
+
<span class='name'>endpoint</span>
|
577
|
+
|
578
|
+
|
579
|
+
<span class='type'>(<tt>String</tt>)</span>
|
580
|
+
|
581
|
+
|
582
|
+
|
583
|
+
—
|
584
|
+
<div class='inline'>
|
585
|
+
<p>The endpoint to exclude from caching.</p>
|
586
|
+
</div>
|
587
|
+
|
588
|
+
</li>
|
589
|
+
|
590
|
+
</ul>
|
591
|
+
|
592
|
+
|
593
|
+
</div><table class="source_code">
|
594
|
+
<tr>
|
595
|
+
<td>
|
596
|
+
<pre class="lines">
|
597
|
+
|
598
|
+
|
599
|
+
28
|
600
|
+
29
|
601
|
+
30</pre>
|
602
|
+
</td>
|
603
|
+
<td>
|
604
|
+
<pre class="code"><span class="info file"># File 'lib/api_wrapper/cache/cache_policy.rb', line 28</span>
|
605
|
+
|
606
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_add_no_cache_endpoint'>add_no_cache_endpoint</span><span class='lparen'>(</span><span class='id identifier rubyid_endpoint'>endpoint</span><span class='rparen'>)</span>
|
607
|
+
<span class='ivar'>@no_cache_endpoints</span> <span class='op'><<</span> <span class='id identifier rubyid_endpoint'>endpoint</span>
|
608
|
+
<span class='kw'>end</span></pre>
|
609
|
+
</td>
|
610
|
+
</tr>
|
611
|
+
</table>
|
612
|
+
</div>
|
613
|
+
|
614
|
+
<div class="method_details ">
|
615
|
+
<h3 class="signature " id="fetch-instance_method">
|
616
|
+
|
617
|
+
#<strong>fetch</strong>(endpoint, force_refresh: false) { ... } ⇒ <tt>Object</tt>
|
618
|
+
|
619
|
+
|
620
|
+
|
621
|
+
|
622
|
+
|
623
|
+
</h3><div class="docstring">
|
624
|
+
<div class="discussion">
|
625
|
+
|
626
|
+
<p>Fetches the data for the given endpoint, using cache if applicable.</p>
|
627
|
+
|
628
|
+
|
629
|
+
</div>
|
630
|
+
</div>
|
631
|
+
<div class="tags">
|
632
|
+
<p class="tag_title">Parameters:</p>
|
633
|
+
<ul class="param">
|
634
|
+
|
635
|
+
<li>
|
636
|
+
|
637
|
+
<span class='name'>endpoint</span>
|
638
|
+
|
639
|
+
|
640
|
+
<span class='type'>(<tt>String</tt>)</span>
|
641
|
+
|
642
|
+
|
643
|
+
|
644
|
+
—
|
645
|
+
<div class='inline'>
|
646
|
+
<p>The endpoint to fetch data for.</p>
|
647
|
+
</div>
|
648
|
+
|
649
|
+
</li>
|
650
|
+
|
651
|
+
<li>
|
652
|
+
|
653
|
+
<span class='name'>force_refresh</span>
|
654
|
+
|
655
|
+
|
656
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
657
|
+
|
658
|
+
|
659
|
+
<em class="default">(defaults to: <tt>false</tt>)</em>
|
660
|
+
|
661
|
+
|
662
|
+
—
|
663
|
+
<div class='inline'>
|
664
|
+
<p>Whether to force refresh the data, bypassing the cache.</p>
|
665
|
+
</div>
|
666
|
+
|
667
|
+
</li>
|
668
|
+
|
669
|
+
</ul>
|
670
|
+
|
671
|
+
<p class="tag_title">Yields:</p>
|
672
|
+
<ul class="yield">
|
673
|
+
|
674
|
+
<li>
|
675
|
+
|
676
|
+
|
677
|
+
<span class='type'></span>
|
678
|
+
|
679
|
+
|
680
|
+
|
681
|
+
|
682
|
+
<div class='inline'>
|
683
|
+
<p>The block that fetches fresh data if cache is not used or is stale.</p>
|
684
|
+
</div>
|
685
|
+
|
686
|
+
</li>
|
687
|
+
|
688
|
+
</ul>
|
689
|
+
<p class="tag_title">Returns:</p>
|
690
|
+
<ul class="return">
|
691
|
+
|
692
|
+
<li>
|
693
|
+
|
694
|
+
|
695
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
696
|
+
|
697
|
+
|
698
|
+
|
699
|
+
—
|
700
|
+
<div class='inline'>
|
701
|
+
<p>The data fetched from cache or fresh data.</p>
|
702
|
+
</div>
|
703
|
+
|
704
|
+
</li>
|
705
|
+
|
706
|
+
</ul>
|
707
|
+
|
708
|
+
</div><table class="source_code">
|
709
|
+
<tr>
|
710
|
+
<td>
|
711
|
+
<pre class="lines">
|
712
|
+
|
713
|
+
|
714
|
+
62
|
715
|
+
63
|
716
|
+
64
|
717
|
+
65
|
718
|
+
66
|
719
|
+
67
|
720
|
+
68</pre>
|
721
|
+
</td>
|
722
|
+
<td>
|
723
|
+
<pre class="code"><span class="info file"># File 'lib/api_wrapper/cache/cache_policy.rb', line 62</span>
|
724
|
+
|
725
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_endpoint'>endpoint</span><span class='comma'>,</span> <span class='label'>force_refresh:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
726
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_force_refresh'>force_refresh</span> <span class='op'>||</span> <span class='op'>!</span><span class='id identifier rubyid_use_cache?'>use_cache?</span><span class='lparen'>(</span><span class='id identifier rubyid_endpoint'>endpoint</span><span class='rparen'>)</span>
|
727
|
+
<span class='id identifier rubyid_fetch_fresh_data'>fetch_fresh_data</span><span class='lparen'>(</span><span class='id identifier rubyid_endpoint'>endpoint</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
728
|
+
<span class='kw'>else</span>
|
729
|
+
<span class='id identifier rubyid_fetch_cached_or_fresh_data'>fetch_cached_or_fresh_data</span><span class='lparen'>(</span><span class='id identifier rubyid_endpoint'>endpoint</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
730
|
+
<span class='kw'>end</span>
|
731
|
+
<span class='kw'>end</span></pre>
|
732
|
+
</td>
|
733
|
+
</tr>
|
734
|
+
</table>
|
735
|
+
</div>
|
736
|
+
|
737
|
+
<div class="method_details ">
|
738
|
+
<h3 class="signature " id="ttl_for-instance_method">
|
739
|
+
|
740
|
+
#<strong>ttl_for</strong>(endpoint) ⇒ <tt>Integer</tt>
|
741
|
+
|
742
|
+
|
743
|
+
|
744
|
+
|
745
|
+
|
746
|
+
</h3><div class="docstring">
|
747
|
+
<div class="discussion">
|
748
|
+
|
749
|
+
<p>Returns the TTL for a specific endpoint. Defaults to the global TTL if no custom TTL is set.</p>
|
750
|
+
|
751
|
+
|
752
|
+
</div>
|
753
|
+
</div>
|
754
|
+
<div class="tags">
|
755
|
+
<p class="tag_title">Parameters:</p>
|
756
|
+
<ul class="param">
|
757
|
+
|
758
|
+
<li>
|
759
|
+
|
760
|
+
<span class='name'>endpoint</span>
|
761
|
+
|
762
|
+
|
763
|
+
<span class='type'>(<tt>String</tt>)</span>
|
764
|
+
|
765
|
+
|
766
|
+
|
767
|
+
—
|
768
|
+
<div class='inline'>
|
769
|
+
<p>The endpoint to fetch the TTL for.</p>
|
770
|
+
</div>
|
771
|
+
|
772
|
+
</li>
|
773
|
+
|
774
|
+
</ul>
|
775
|
+
|
776
|
+
<p class="tag_title">Returns:</p>
|
777
|
+
<ul class="return">
|
778
|
+
|
779
|
+
<li>
|
780
|
+
|
781
|
+
|
782
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
783
|
+
|
784
|
+
|
785
|
+
|
786
|
+
—
|
787
|
+
<div class='inline'>
|
788
|
+
<p>The TTL in seconds.</p>
|
789
|
+
</div>
|
790
|
+
|
791
|
+
</li>
|
792
|
+
|
793
|
+
</ul>
|
794
|
+
|
795
|
+
</div><table class="source_code">
|
796
|
+
<tr>
|
797
|
+
<td>
|
798
|
+
<pre class="lines">
|
799
|
+
|
800
|
+
|
801
|
+
44
|
802
|
+
45
|
803
|
+
46</pre>
|
804
|
+
</td>
|
805
|
+
<td>
|
806
|
+
<pre class="code"><span class="info file"># File 'lib/api_wrapper/cache/cache_policy.rb', line 44</span>
|
807
|
+
|
808
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_ttl_for'>ttl_for</span><span class='lparen'>(</span><span class='id identifier rubyid_endpoint'>endpoint</span><span class='rparen'>)</span>
|
809
|
+
<span class='ivar'>@custom_ttls</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_endpoint'>endpoint</span><span class='comma'>,</span> <span class='ivar'>@global_ttl</span><span class='rparen'>)</span>
|
810
|
+
<span class='kw'>end</span></pre>
|
811
|
+
</td>
|
812
|
+
</tr>
|
813
|
+
</table>
|
814
|
+
</div>
|
815
|
+
|
816
|
+
<div class="method_details ">
|
817
|
+
<h3 class="signature " id="use_cache?-instance_method">
|
818
|
+
|
819
|
+
#<strong>use_cache?</strong>(endpoint) ⇒ <tt>Boolean</tt>
|
820
|
+
|
821
|
+
|
822
|
+
|
823
|
+
|
824
|
+
|
825
|
+
</h3><div class="docstring">
|
826
|
+
<div class="discussion">
|
827
|
+
|
828
|
+
<p>Determines if caching should be used for the given endpoint.</p>
|
829
|
+
|
830
|
+
|
831
|
+
</div>
|
832
|
+
</div>
|
833
|
+
<div class="tags">
|
834
|
+
<p class="tag_title">Parameters:</p>
|
835
|
+
<ul class="param">
|
836
|
+
|
837
|
+
<li>
|
838
|
+
|
839
|
+
<span class='name'>endpoint</span>
|
840
|
+
|
841
|
+
|
842
|
+
<span class='type'>(<tt>String</tt>)</span>
|
843
|
+
|
844
|
+
|
845
|
+
|
846
|
+
—
|
847
|
+
<div class='inline'>
|
848
|
+
<p>The endpoint to check.</p>
|
849
|
+
</div>
|
850
|
+
|
851
|
+
</li>
|
852
|
+
|
853
|
+
</ul>
|
854
|
+
|
855
|
+
<p class="tag_title">Returns:</p>
|
856
|
+
<ul class="return">
|
857
|
+
|
858
|
+
<li>
|
859
|
+
|
860
|
+
|
861
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
862
|
+
|
863
|
+
|
864
|
+
|
865
|
+
—
|
866
|
+
<div class='inline'>
|
867
|
+
<p>True if caching is enabled for the endpoint, false otherwise.</p>
|
868
|
+
</div>
|
869
|
+
|
870
|
+
</li>
|
871
|
+
|
872
|
+
</ul>
|
873
|
+
|
874
|
+
</div><table class="source_code">
|
875
|
+
<tr>
|
876
|
+
<td>
|
877
|
+
<pre class="lines">
|
878
|
+
|
879
|
+
|
880
|
+
52
|
881
|
+
53
|
882
|
+
54</pre>
|
883
|
+
</td>
|
884
|
+
<td>
|
885
|
+
<pre class="code"><span class="info file"># File 'lib/api_wrapper/cache/cache_policy.rb', line 52</span>
|
886
|
+
|
887
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_use_cache?'>use_cache?</span><span class='lparen'>(</span><span class='id identifier rubyid_endpoint'>endpoint</span><span class='rparen'>)</span>
|
888
|
+
<span class='op'>!</span><span class='ivar'>@no_cache_endpoints</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_endpoint'>endpoint</span><span class='rparen'>)</span>
|
889
|
+
<span class='kw'>end</span></pre>
|
890
|
+
</td>
|
891
|
+
</tr>
|
892
|
+
</table>
|
893
|
+
</div>
|
894
|
+
|
895
|
+
</div>
|
896
|
+
|
897
|
+
</div>
|
898
|
+
|
899
|
+
<div id="footer">
|
900
|
+
Generated on Mon Sep 16 23:22:30 2024 by
|
901
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
902
|
+
0.9.37 (ruby-3.2.2).
|
903
|
+
</div>
|
904
|
+
|
905
|
+
</div>
|
906
|
+
</body>
|
907
|
+
</html>
|