All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.ebeaninternal.server.cache.CacheManagerOptions Maven / Gradle / Ivy

There is a newer version: 15.6.0
Show newest version
package io.ebeaninternal.server.cache;

import io.ebean.cache.ServerCacheFactory;
import io.ebean.cache.ServerCacheOptions;
import io.ebean.config.CurrentTenantProvider;
import io.ebean.config.ServerConfig;
import io.ebeaninternal.server.cluster.ClusterManager;

/**
 * Configuration options when creating the default cache manager.
 */
public class CacheManagerOptions {

  private final ClusterManager clusterManager;

  private final ServerConfig serverConfig;

  private final boolean localL2Caching;

  private CurrentTenantProvider currentTenantProvider;

  private ServerCacheFactory cacheFactory = new DefaultServerCacheFactory();
  private ServerCacheOptions beanDefault = new ServerCacheOptions();
  private ServerCacheOptions queryDefault = new ServerCacheOptions();

  CacheManagerOptions() {
    this.localL2Caching = true;
    this.clusterManager = null;
    this.serverConfig = null;
    this.cacheFactory = new DefaultServerCacheFactory();
    this.beanDefault = new ServerCacheOptions();
    this.queryDefault = new ServerCacheOptions();
  }

  public CacheManagerOptions(ClusterManager clusterManager, ServerConfig serverConfig, boolean localL2Caching) {
    this.clusterManager = clusterManager;
    this.serverConfig = serverConfig;
    this.localL2Caching = localL2Caching;
    this.currentTenantProvider = serverConfig.getCurrentTenantProvider();
  }

  public CacheManagerOptions with(ServerCacheOptions beanDefault, ServerCacheOptions queryDefault) {
    this.beanDefault = beanDefault;
    this.queryDefault = queryDefault;
    return this;
  }

  public CacheManagerOptions with(ServerCacheFactory cacheFactory) {
    this.cacheFactory = cacheFactory;
    return this;
  }

  public CacheManagerOptions with(CurrentTenantProvider currentTenantProvider) {
    this.currentTenantProvider = currentTenantProvider;
    return this;
  }

  public String getServerName() {
    return (serverConfig == null) ? "db" : serverConfig.getName();
  }

  public boolean isLocalL2Caching() {
    return localL2Caching;
  }

  public ServerCacheFactory getCacheFactory() {
    return cacheFactory;
  }

  public ServerCacheOptions getBeanDefault() {
    return beanDefault;
  }

  public ServerCacheOptions getQueryDefault() {
    return queryDefault;
  }

  public CurrentTenantProvider getCurrentTenantProvider() {
    return currentTenantProvider;
  }

  public ClusterManager getClusterManager() {
    return clusterManager;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy