/usr/share/doc/cockpit/guide/cockpit-cache.html is in cockpit-doc 164-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>cockpit.js: Object Cache</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="Cockpit Guide">
<link rel="up" href="api-base1.html" title="API: base1">
<link rel="prev" href="cockpit-util.html" title="cockpit.js: Utilities">
<link rel="next" href="cockpit-manifest.html" title="cockpit.js: Manifests">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
<td><a accesskey="p" href="cockpit-util.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="api-base1.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">Cockpit Guide</th>
<td><a accesskey="n" href="cockpit-manifest.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="cockpit-cache"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2>cockpit.js: Object Cache</h2>
<p>cockpit.js: Object Cache — Caching and sharing data</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<p>If the same information is displayed by multiple components in Cockpit,
<code class="code">cockpit.cache()</code> provides a way to share data between them. The shared
data should be simple objects, arrays, and values, and not contain functions or
other objects.</p>
</div>
<div class="refsection">
<a name="cockpit-cache-func"></a><h2>cockpit.cache()</h2>
<pre class="programlisting">
cache = cockpit.cache(key, provider, consumer)
</pre>
<p>Create a new cache object. The <code class="code">key</code> should be a globally unique string
that describes the data being cached. This string must describe the data, across all
machines and all versions of cockpit. It is customary to include a version number in
the <code class="code">key</code> string.</p>
<pre class="programlisting">
function provider(result, key) {
result("myvalue");
return {
close: function() {
/* closed */
}
};
}
</pre>
<p>The <code class="code">provider</code> is a function that will be invoked to start retrieving
data for the cache. It will be passed a <code class="code">result</code> function as its first
argument. The <code class="code">result</code> should be invoked whenever new data is available.
The <code class="code">key</code> argument matches the key string the cache was created with.</p>
<p>The <code class="code">provider</code> can return an object with a <code class="code">close</code> method.
This method will be invoked when the cache no longer needs data from the provider.</p>
<pre class="programlisting">
function consumer(value, key) {
/* ... */
}
</pre>
<p>The <code class="code">consumer</code> is a function that will be passed new values when they
are available, whether they come from the <code class="code">provider</code> or a source in a
different component/frame.</p>
</div>
<div class="refsection">
<a name="cockpit-cache-close"></a><h2>cache.close()</h2>
<pre class="programlisting">
cache.close()
</pre>
<p>Close a cache and stop calling its <code class="code">consumer</code>. If the <code class="code">provider</code>
was invoked, then the <code class="code">close()</code> method it returned will be invoked.</p>
</div>
</div>
<div class="footer"><hr></div>
</body>
</html>
|