@qikdev/sdk 1.0.12 → 1.0.13
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.
- package/dist/main.js +796 -759
- package/package.json +1 -1
- package/src/api/qik.access.js +177 -201
- package/src/api/qik.api.js +55 -28
- package/src/api/qik.auth.js +181 -113
- package/src/api/qik.cache.js +29 -7
- package/src/api/qik.content.js +275 -147
- package/src/api/qik.core.js +19 -28
- package/src/api/qik.files.js +48 -38
- package/src/api/qik.filter.js +148 -207
- package/src/api/qik.geo.js +59 -42
- package/src/api/qik.socket.js +117 -43
- package/src/api/qik.storage.js +17 -8
- package/src/api/qik.system.js +6 -5
- package/src/api/qik.utils.js +244 -199
- package/src/version.js +1 -1
package/src/api/qik.cache.js
CHANGED
|
@@ -7,10 +7,17 @@ var caches = {};
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* @classdesc
|
|
10
|
+
* @classdesc Named in-memory caches shared by the whole page (LRU: the least recently used entries are dropped
|
|
11
|
+
* when a cache is full). The SDK keeps the content glossary in one; you can create your own to remember
|
|
12
|
+
* expensive lookups. Nothing is persisted: caches are lost on reload, and all of them are cleared on
|
|
13
|
+
* logout and organisation switch.
|
|
11
14
|
* @alias cache
|
|
12
15
|
* @class
|
|
13
16
|
* @hideconstructor
|
|
17
|
+
* @example
|
|
18
|
+
* const cache = sdk.cache.get('my-lookups', { max: 100 });
|
|
19
|
+
* cache.set('answer', 42);
|
|
20
|
+
* cache.get('answer'); // 42
|
|
14
21
|
*/
|
|
15
22
|
var QikCache = {
|
|
16
23
|
|
|
@@ -18,8 +25,12 @@ var QikCache = {
|
|
|
18
25
|
|
|
19
26
|
|
|
20
27
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
28
|
+
* Empties every cache created with sdk.cache.get (the caches themselves stay available, just empty).
|
|
29
|
+
* sdk.auth.logout() and sdk.auth.changeOrganisation() call this for you.
|
|
30
|
+
* @alias cache.reset
|
|
31
|
+
* @returns {undefined}
|
|
32
|
+
* @example
|
|
33
|
+
* sdk.cache.reset();
|
|
23
34
|
*/
|
|
24
35
|
reset() {
|
|
25
36
|
Object.entries(caches).forEach(([key, cache]) => {
|
|
@@ -34,10 +45,21 @@ var QikCache = {
|
|
|
34
45
|
///////////////////////////////////////////////////
|
|
35
46
|
|
|
36
47
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* @
|
|
40
|
-
* @
|
|
48
|
+
* Returns the cache with this name, creating it the first time. Later calls with the same name return the
|
|
49
|
+
* same cache, whatever options they pass.
|
|
50
|
+
* @alias cache.get
|
|
51
|
+
* @param {String} key The cache's name.
|
|
52
|
+
* @param {Object} [options] lru-cache options, used only when the cache is created. Default { max: 5 } (five entries).
|
|
53
|
+
* @param {Number} [options.max] Maximum number of entries.
|
|
54
|
+
* @param {Number} [options.ttl] Milliseconds before an entry expires.
|
|
55
|
+
* @returns {LRUCache} An lru-cache instance: get(key), set(key, value), has(key), delete(key), clear().
|
|
56
|
+
* @example
|
|
57
|
+
* const cache = sdk.cache.get('people', { max: 500, ttl: 60000 });
|
|
58
|
+
* let person = cache.get(id);
|
|
59
|
+
* if (!person) {
|
|
60
|
+
* person = await sdk.content.get(id);
|
|
61
|
+
* cache.set(id, person);
|
|
62
|
+
* }
|
|
41
63
|
*/
|
|
42
64
|
get(key, options) {
|
|
43
65
|
options = options || {max:5};
|