You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I using yar as my session plugin along with catbox-redis.
This is my configurations:
const Hapi = require('hapi');
const yar = require('yar');
const hapiServer = new Hapi.Server({
cache: {
engine: require('catbox-redis'),
host: redisAddress,
port: redisPort
}
});
hapiServer.connection({
host: hapiHostAddress,
port: hapiPort
});
hapiServer.route({
method: 'GET',
path: '/test/{key}/{value}',
handler: function (request, reply) {
// In MongoDB, this data will be stored in the
// "!yar" collection within the "hapi-cache" database.
var data = {};
data[request.params.key] = request.params.value;
request.yar.set('example', data);
return reply(request.yar.get('example'));
}
});
const yarOptions = {
storeBlank: false,
maxCookieSize: 0,
cache: {
expiresIn: 24 * 60 * 60 * 1000
},
cookieOptions: {
password: 'the-password-must-be-at-least-32-characters-long',
isSecure: true
}
};
hapiServer.register({
register: yar,
options: yarOptions
}, function (err) {
// start your hapiServer after plugin registration
hapiServer.start(function (err) {
console.log('info', 'Server running at: ' + hapiServer.info.uri)
})
})
The problem is that request.yar.get('example') returns the correct data but it doesn't use redis (I'm monitoring redis with redis-cli monitor) even though request.yar.set('example', data) saves the data to redis.
Shouldn't it fetch from redis catch instead?
The text was updated successfully, but these errors were encountered:
At a glance your configuration looks good. The cookie data should be retrieved from redis during onPreAuth if the yar cookie session id is sent with the request. The cookie data is only written to redis during onPreResponse. Between onPreAuth and onPreResponse the cookie data is maintained in memory, which is why you don't see yar.get() reaching out to redis.
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.
lockbot
locked as resolved and limited conversation to collaborators
Jan 9, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
supportQuestions, discussions, and general support
I using
yar
as my session plugin along withcatbox-redis
.This is my configurations:
The problem is that
request.yar.get('example')
returns the correct data but it doesn't use redis (I'm monitoring redis withredis-cli monitor
) even thoughrequest.yar.set('example', data)
saves the data to redis.Shouldn't it fetch from redis catch instead?
The text was updated successfully, but these errors were encountered: