Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-10-22 15:22:19 +03:00
parent cd9f6b53e7
commit e1c5dbebd5
2 changed files with 14 additions and 5 deletions

View File

@ -89,6 +89,17 @@ var pwpath = require('../path')
// -> <data> // -> <data>
// -> <promise> // -> <promise>
// //
// NOTE: the main differences between the 'get', 'lazy' and 'cached' actions:
// 'get'
// generate/merge are all sync/async as defined
// when cached value available validate and return either the cached value or generate
// 'lazy'
// XXX
// 'cached'
// call get in background
// return cached value or undefined
//
//
// //
// Special methods: // Special methods:
// //
@ -238,22 +249,19 @@ function(name, generate, options={}){
&& res instanceof Promise) ? && res instanceof Promise) ?
this[cache] this[cache]
: res } : res }
// action: cached... // action: cached...
if(action == 'cached'){ if(action == 'cached'){
_deferred(this, 'get') _deferred(this, 'get')
return this[cache] } return this[cache] }
// action: local... // action: local...
// NOTE: this "cascade" of actions is interdependent...
// NOTE: this is intentionally not cached... // NOTE: this is intentionally not cached...
if(action == 'local'){ if(action == 'local'){
return _make(this) } return _make(this) }
// action: clear/reset... // action: clear/reset...
if(action == 'clear' if(action == 'clear'
|| action == 'reset'){ || action == 'reset'){
delete this[cache] } delete this[cache] }
// action: clear...
if(action == 'clear'){ if(action == 'clear'){
return } return }

View File

@ -17,7 +17,8 @@
* - CLI * - CLI
* *
* *
* XXX add 'status' action to .index(..) and makeIndex(..) * XXX ASAP move index stuff to pwiki/index.js
* XXX can index validation be async???
* XXX INDEX / CACHE: * XXX INDEX / CACHE:
* - centralized * - centralized
* - nestable * - nestable