Overview

JAWCE session / cache management

JAWCE comes with default SessionManager implementations out-of-the-box

Default implementations

  • FileBasedSessionManager
  • CaffeineSessionManager
  • HazelcastSessionManager
  • LMDBSessionManager

You can use any of the default implementations or switch any of them at any time.

The sample chatbot uses FileBasedSessionManager by default

Session methods

All session managements implements a single ISessionManager interface. You can also implement your own session manager and use it in your chatbot

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 are not tightly coupled with JAWCE main engine.

You can use this in any other project