Hello,
I wrote a Kibana plugin last summer that employs Catbox caching from Hapi, and it's been working quite well until the release of Kibana 6.5.
A simple example:
module.exports = function (server, options) {
const cache = server.cache({ segment: 'segment1', expiresIn: 7200000 });
cache.set('key', 'value', 0, (err) => {});
cache.get('key', (err, value) => {
if (err) {
server.log(['error'], 'Error is: ' + err);
}
else {
server.log(['info'], 'Value is: ' + value);
}
});
};
This produces the following error message:
log [00:18:41.318] [error] Error is: Error: Disconnected
In 6.5 and later, it seems that the memory engine underlying the Catbox policy object is never started, so any get/set calls fail. I've managed to get around this problem by manually starting the engine like so:
if (!cache.isReady()) {
cache._cache.connection.start(() => {
server.log(['info'], 'Started memory cache');
});
}
Which outputs the desired log messages:
log [00:22:01.729] [info] Started memory cache
log [00:22:01.736] [info] Value is: value
Obviously this isn't the preferred approach, however, as it accesses private members of the cache object.
I was going to open an issue on GitHub, but wasn't sure if this qualifies as a bug, or if there's something that I'm missing. Thoughts?
Thanks in advance!