Overview
session / cache management
The session manager handles only 1 task: to manage (save, retrieve, delete) user and engine abitrary data
It stores engine data which keeps track of where the user is in your conversational flows.
WCE comes with default SessionManager
implementations out-of-the-box
Jawce Default implementations
- FileBasedSessionManager
- CaffeineSessionManager
- HazelcastSessionManager
- LMDBSessionManager
You can use any of the default implementations or switch any of them at any time.
Session methods
All session managers implements a single ISessionManager
interface.
You must implement this class for your own session management logic.
See a Java interface representation of ISessionManager below.
This is the same class or Python abstract class too
ISessionManager.session(<session-id>)
must return a ISessionManager instance.
Nomatter how many times it called, it should return the session object of the passed session-id
public interface ISessionManager {
ISessionManager session(String user);
void save(String user, String key, Object data);
Object get(String user, String key);
// get all user data
Map<String, Object> fetchAll(String user);
// remove data by key
void evict(String user, String key);
void clear(String user);
// save non-user related data - accessible to all users
void saveGlobal(String key, Object data);
void evictGlobal(String key);
// clear all user data except keys in > retain array
void clear(String user, List<String> retain);
// remove prop data by key
boolean evictProp(String user, String propKey);
Object getFromProps(String user, String propKey);
Map<String, Object> getUserProps(String user);
void saveProp(String user, String key, Object data);
// --- utility methods
<T> T get(String user, String key, Class<T> type);
<T> T getGlobal(String key, Class<T> type);
<T> T getFromProps(String user, String propKey, Class<T> propType);
}
ISessionManager
and its default implementations can be used independently.
You can use this the session manager without tying it to the engine.