Exemplo n.º 1
0
  private void configureCacheManager(CacheStore cacheStore) {
    context.cacheManager = new CacheManager(cacheStore);

    if (!context.test) {
      CacheController controller = new CacheController(context.cacheManager);
      context.httpServer.get("/management/cache", controller::list);
      context.httpServer.get("/management/cache/:name/:key", controller::get);
      context.httpServer.delete("/management/cache/:name/:key", controller::delete);
    }
  }
Exemplo n.º 2
0
 public void local() {
   logger.info("create local session provider");
   LocalSessionStore sessionStore = new LocalSessionStore();
   context
       .scheduler()
       .addTrigger(
           new FixedRateTrigger(
               "cleanup-local-session",
               new CleanupLocalSessionStoreJob(sessionStore),
               Duration.ofMinutes(30)));
   context.httpServer.siteManager.sessionManager.sessionStore(sessionStore);
 }
Exemplo n.º 3
0
  public void redis(String host) {
    if (context.isTest()) {
      logger.info("use local session during test");
      local();
    } else {
      logger.info("create redis session provider, host={}", host);

      RedisImpl redis = new RedisImpl();
      redis.host(host);
      redis.pool.name("redis-session");
      context
          .scheduler()
          .addTrigger(
              new FixedRateTrigger(
                  "refresh-redis-session-pool",
                  new RefreshPoolJob(redis.pool),
                  Duration.ofMinutes(5)));

      context.shutdownHook.add(redis::close);
      context.httpServer.siteManager.sessionManager.sessionStore(new RedisSessionStore(redis));
    }
  }