Implement JSDoc and embedding into our navbar without obvious CSS conflicts
[ndcode_site.git] / jsdoc / BuildCache.html
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4     <meta charset="utf-8">
5     <title>JSDoc: Class: BuildCache</title>
6
7     <script src="scripts/prettify/prettify.js"> </script>
8     <script src="scripts/prettify/lang-css.js"> </script>
9     <!--[if lt IE 9]>
10       <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11     <![endif]-->
12     <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13     <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14 </head>
15
16 <body>
17
18 <div id="main">
19
20     <h1 class="page-title">Class: BuildCache</h1>
21
22     
23
24
25
26
27 <section>
28
29 <header>
30     
31         <h2><span class="attribs"><span class="type-signature"></span></span>BuildCache<span class="signature">(diag)</span><span class="type-signature"></span></h2>
32         
33     
34 </header>
35
36 <article>
37     <div class="container-overview">
38     
39         
40
41     
42
43     
44     <h4 class="name" id="BuildCache"><span class="type-signature"></span>new BuildCache<span class="signature">(diag)</span><span class="type-signature"></span></h4>
45     
46
47     
48
49
50
51 <div class="description">
52     Constructs a cache object. The cache object is intended to store objects of
53 arbitrary JavaScript type, which are built from on-disk source files of some
54 kind. The cache tracks the source files of each object, and makes sure the
55 objects are rebuilt as required if the source files change on disk.
56 </div>
57
58
59
60
61
62
63
64
65
66     <h5>Parameters:</h5>
67     
68
69 <table class="params">
70     <thead>
71     <tr>
72         
73         <th>Name</th>
74         
75
76         <th>Type</th>
77
78         
79
80         
81
82         <th class="last">Description</th>
83     </tr>
84     </thead>
85
86     <tbody>
87     
88
89         <tr>
90             
91                 <td class="name"><code>diag</code></td>
92             
93
94             <td class="type">
95             
96                 
97 <span class="param-type">boolean</span>
98
99
100             
101             </td>
102
103             
104
105             
106
107             <td class="description last">Should diagnostic messages be printed to the
108   console.</td>
109         </tr>
110
111     
112     </tbody>
113 </table>
114
115
116
117
118
119
120 <dl class="details">
121
122     
123
124     
125
126     
127
128     
129
130     
131
132     
133
134     
135
136     
137
138     
139
140     
141
142     
143
144     
145
146     
147     <dt class="tag-source">Source:</dt>
148     <dd class="tag-source"><ul class="dummy"><li>
149         <a href="BuildCache.js.html">BuildCache.js</a>, <a href="BuildCache.js.html#line39">line 39</a>
150     </li></ul></dd>
151     
152
153     
154
155     
156
157     
158 </dl>
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179     
180     </div>
181
182     
183
184     
185
186     
187
188     
189
190     
191
192     
193
194     
195
196     
197         <h3 class="subsection-title">Methods</h3>
198
199         
200             
201
202     
203
204     
205     <h4 class="name" id="build"><span class="type-signature"></span>build<span class="signature">(key, result)</span><span class="type-signature"></span></h4>
206     
207
208     
209
210
211
212 <div class="description">
213     Abstract method which is expected to build and return an object, given its
214 key. Called from "get()" when the object does not exist or is out of date.
215
216 If this method throws an exception, the key will be deleted from the cache
217 and the exception re-thrown to the caller of "get()". If there are multiple
218 callers to "get()" blocking and waiting for the build, they all receive the
219 same exception object. So one has to be careful the exception is shareable.
220 </div>
221
222
223
224
225
226
227
228
229
230     <h5>Parameters:</h5>
231     
232
233 <table class="params">
234     <thead>
235     <tr>
236         
237         <th>Name</th>
238         
239
240         <th>Type</th>
241
242         
243
244         
245
246         <th class="last">Description</th>
247     </tr>
248     </thead>
249
250     <tbody>
251     
252
253         <tr>
254             
255                 <td class="name"><code>key</code></td>
256             
257
258             <td class="type">
259             
260                 
261 <span class="param-type">string</span>
262
263
264             
265             </td>
266
267             
268
269             
270
271             <td class="description last">Usually the path to the main source file on disk.</td>
272         </tr>
273
274     
275
276         <tr>
277             
278                 <td class="name"><code>result</code></td>
279             
280
281             <td class="type">
282             
283                 
284 <span class="param-type">object</span>
285
286
287             
288             </td>
289
290             
291
292             
293
294             <td class="description last">A dictionary to receive information about the built
295   object, you can optionally set "result.deps" to a list of dependency files
296   whose modification would invalidate the just-built and cached object.</td>
297         </tr>
298
299     
300     </tbody>
301 </table>
302
303
304
305
306
307
308 <dl class="details">
309
310     
311
312     
313
314     
315
316     
317
318     
319
320     
321
322     
323
324     
325
326     
327
328     
329
330     
331
332     
333
334     
335     <dt class="tag-source">Source:</dt>
336     <dd class="tag-source"><ul class="dummy"><li>
337         <a href="BuildCache.js.html">BuildCache.js</a>, <a href="BuildCache.js.html#line61">line 61</a>
338     </li></ul></dd>
339     
340
341     
342
343     
344
345     
346 </dl>
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367         
368             
369
370     
371
372     
373     <h4 class="name" id="get"><span class="type-signature"></span>get<span class="signature">(key, once)</span><span class="type-signature"></span></h4>
374     
375
376     
377
378
379
380 <div class="description">
381     Retrieves the object stored in the cache under "key". If "key" already
382 exists in the cache, then it will be checked for up-to-dateness. If present
383 and up-to-date then its object is returned directly. Otherwise the abstract
384 "build()" method is called to attempt to build the object, and either an
385 exception is thrown or the built object is stored and return to the caller.
386
387 Other callers requsting the same object while the original build progresses
388 will be blocked, and all will wait for the build to complete. In this time,
389 no new up-to-date check will be initiated. But as soon as the build is
390 completed and the cache updated, further up-to-date checks become possible.
391
392 An interesting alternate usage is provided for objects whose contents only
393 matter if they have been rebuilt since last time. For example, suppose we
394 want to periodically read a configuration file, and then possibly restart
395 some long-running process if the configuration has changed. Then it is not
396 necessary to store the result of configuration parsing in the cache, since
397 it is only needed momentarily (while we're actually restarting the process).
398 In such case, pass "once = true" and an "undefined" return means no change.
399 </div>
400
401
402
403
404
405
406
407
408
409     <h5>Parameters:</h5>
410     
411
412 <table class="params">
413     <thead>
414     <tr>
415         
416         <th>Name</th>
417         
418
419         <th>Type</th>
420
421         
422
423         
424
425         <th class="last">Description</th>
426     </tr>
427     </thead>
428
429     <tbody>
430     
431
432         <tr>
433             
434                 <td class="name"><code>key</code></td>
435             
436
437             <td class="type">
438             
439                 
440 <span class="param-type">string</span>
441
442
443             
444             </td>
445
446             
447
448             
449
450             <td class="description last">Usually the path to the main source file on disk.</td>
451         </tr>
452
453     
454
455         <tr>
456             
457                 <td class="name"><code>once</code></td>
458             
459
460             <td class="type">
461             
462                 
463 <span class="param-type">boolean</span>
464
465
466             
467             </td>
468
469             
470
471             
472
473             <td class="description last">If "true", it means the returned object will only be
474   used once. See above for a more comprehensive discussion of this feature.</td>
475         </tr>
476
477     
478     </tbody>
479 </table>
480
481
482
483
484
485
486 <dl class="details">
487
488     
489
490     
491
492     
493
494     
495
496     
497
498     
499
500     
501
502     
503
504     
505
506     
507
508     
509
510     
511
512     
513     <dt class="tag-source">Source:</dt>
514     <dd class="tag-source"><ul class="dummy"><li>
515         <a href="BuildCache.js.html">BuildCache.js</a>, <a href="BuildCache.js.html#line90">line 90</a>
516     </li></ul></dd>
517     
518
519     
520
521     
522
523     
524 </dl>
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545         
546             
547
548     
549
550     
551     <h4 class="name" id="kick"><span class="type-signature"></span>kick<span class="signature">()</span><span class="type-signature"></span></h4>
552     
553
554     
555
556
557
558 <div class="description">
559     Call this periodically to allow the cache to clean itself of stale objects.
560 It can be called as often as convenient, but since the cache can be large,
561 the frequency of calls to "kick()" should be kept low. For example, if
562 unreferenced objects should be kept for one day, then call "kick()" once
563 per hour, and the actual lifetime will be at least 24 and up to 25 hours.
564
565 The cache cleaning is not yet implemented, but the dummy "kick()" function
566 is provided so that you can start to put the cleaning infrastructure in your
567 code already. The constructor arguments might change later for this feature.
568 </div>
569
570
571
572
573
574
575
576
577
578
579
580
581
582 <dl class="details">
583
584     
585
586     
587
588     
589
590     
591
592     
593
594     
595
596     
597
598     
599
600     
601
602     
603
604     
605
606     
607
608     
609     <dt class="tag-source">Source:</dt>
610     <dd class="tag-source"><ul class="dummy"><li>
611         <a href="BuildCache.js.html">BuildCache.js</a>, <a href="BuildCache.js.html#line165">line 165</a>
612     </li></ul></dd>
613     
614
615     
616
617     
618
619     
620 </dl>
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641         
642     
643
644     
645
646     
647 </article>
648
649 </section>
650
651
652
653
654 </div>
655
656 <nav>
657     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="BuildCache.html">BuildCache</a></li></ul>
658 </nav>
659
660 <br class="clear">
661
662 <footer>
663     Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Wed Feb 05 2020 00:11:43 GMT+1100 (Australian Eastern Daylight Time)
664 </footer>
665
666 <script> prettyPrint(); </script>
667 <script src="scripts/linenumber.js"> </script>
668 </body>
669 </html>