MCPcopy
hub / github.com/hapijs/hapi / _cachePolicy

Method _cachePolicy

lib/core.js:622–640  ·  view source on GitHub ↗
(options, _segment, realm)

Source from the content-addressed store, hash-verified

620 }
621
622 _cachePolicy(options, _segment, realm) {
623
624 options = Config.apply('cachePolicy', options);
625
626 const plugin = realm?.plugin;
627 const segment = options.segment ?? _segment ?? (plugin ? `!${plugin}` : '');
628 Hoek.assert(segment, 'Missing cache segment name');
629
630 const cacheName = options.cache ?? '_default';
631 const cache = this.caches.get(cacheName);
632 Hoek.assert(cache, 'Unknown cache', cacheName);
633 Hoek.assert(!cache.segments[segment] || cache.shared || options.shared, 'Cannot provision the same cache segment more than once');
634 cache.segments[segment] = true;
635
636 const policy = new Catbox.Policy(options, cache.client, segment);
637 this.events.emit('cachePolicy', [policy, options.cache, segment]);
638
639 return policy;
640 }
641
642 log(tags, data) {
643

Callers 2

_addMethod · 0.80
policyFunction · 0.80

Calls 1

emitMethod · 0.80

Tested by

no test coverage detected