This implements the User Variable Session Manager Interface, catching rivescript-js up to its Go, Python and Java cousins.
This will make it possible to replace the in-memory user variable store with one backed by MongoDB or Redis or anything else, with async support. This is made possible with the async/await feature in modern JavaScript, so that the bot can "pause" anywhere in the middle of a reply() to set and retrieve user variables from storage asynchronously. This means your bot can actively remember variables without you needing to use getUservars() to export them periodically.
The default session manager continues to keep variables in an in-memory object.
Implementations for session managers (e.g. Redis) will come as separate packages on npm, e.g., rivescript-contrib-redis or so.
The usage for you will be like:
const RedisStore = require("rivescript-contrib-redis");
const RiveScript = require("rivescript");
var bot = new RiveScript({
// RedisStore constructor arguments TBD
sessionManager: new RedisStore("localhost:6379"),
});
bot.setUservar("kirsle", "topic", "random") // goes straight to Redis
This implements the User Variable Session Manager Interface, catching rivescript-js up to its Go, Python and Java cousins.
This will make it possible to replace the in-memory user variable store with one backed by MongoDB or Redis or anything else, with async support. This is made possible with the async/await feature in modern JavaScript, so that the bot can "pause" anywhere in the middle of a
reply()
to set and retrieve user variables from storage asynchronously. This means your bot can actively remember variables without you needing to usegetUservars()
to export them periodically.The default session manager continues to keep variables in an in-memory object.
Implementations for session managers (e.g. Redis) will come as separate packages on npm, e.g.,
rivescript-contrib-redis
or so.The usage for you will be like:
Fixes #268