-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.js
More file actions
55 lines (47 loc) · 1.06 KB
/
index.js
File metadata and controls
55 lines (47 loc) · 1.06 KB
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
'use strict'
const Trailpack = require('trailpack')
module.exports = class CacheTrailpack extends Trailpack {
/**
* Validate caches config
*/
validate() {
if (!this.app.config.caches) {
return Promise.reject(
new Error('There no cache.js under ./config,' +
'check it\'s load in ./config/index.js or create it !')
)
}
}
/**
* Check if there some stores, if not set a default one
*/
configure() {
if (this.app.config.caches.stores.length === 0) {
this.app.config.caches.stores = [
// Default Memory Store
{
name: 'memory',
type: 'memory',
max: 500,
ttl: 0
}]
this.app.config.caches.defaults = ['memory']
}
}
/**
* create caching stores
*/
initialize() {
return this.app.services.CacheService.init()
}
unload() {
return this.app.services.CacheService.unload()
}
constructor(app) {
super(app, {
config: require('./config'),
api: require('./api'),
pkg: require('./package')
})
}
}