-
Notifications
You must be signed in to change notification settings - Fork 9
How do I use catbox-memory #790
Comments
Your engine is wrong. Should be |
Updated Server const server = new Server({
port,
routes: {
cors: true,
},
cache: {
name: 'realtime',
engine: new catboxEngine(),
},
}); Error
EDIT: It is using catbox-memory now, it said it needed to be constructed |
What version of hapi are you on? See hapijs/hapi#3871 for info on how to configure the cache. |
"@hapi/catbox-memory": "^4.1.0",
"@hapi/hapi": "^18.3.1",
"@types/hapi__catbox-memory": "^4.1.0",
"@types/hapi__hapi": "^18.2.1", It should be the correct version of catbox-memory for hapi |
I changed it to the example on that page const server = new Server({
port,
routes: {
cors: true,
},
});
server.cache.provision({
provider: {
constructor: require('@hapi/catbox-memory'),
options: {
partition: 'x',
maxByteSize: 10000,
},
},
name: 'countries',
}); const realtimeCache = server.cache({
cache: 'countries',
expiresIn: 1000,
segment: 'realtime',
generateFunc: () => device.getPowerUsage(),
generateTimeout: 2000,
});
server
.route({
method: 'GET',
path: '/tplink/realtime',
handler: realtimeCache.get('realtime'),
}); And it still gives this error
EDIT: This is the full code, it would probably help more then just segments https://paste.nomsy.net/obotaweqoy.js |
Looks like line 80 in your code, handler is missing |
I have never seen in any examples seen a handler option, but I'll try when I'm able to. EDIT: Nevermind, I see what you mean now, I thought you meant my cache needed a handler function but my route was missing the |
I'm trying to setup a basic catbox cache that stores the output for a few seconds in memory, nothing too advanced, as far as I can tell I need @hapi/hapi, @hapi/catbox, and @hapi/catbox-memory.
The text was updated successfully, but these errors were encountered: