| 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 | |