001package io.ebean.cache;
002
003import io.ebean.config.CurrentTenantProvider;
004
005/**
006 * Configuration used to create ServerCache instances.
007 */
008public class ServerCacheConfig {
009
010  private final ServerCacheType type;
011  private final String cacheKey;
012  private final String shortName;
013  private final ServerCacheOptions cacheOptions;
014  private final CurrentTenantProvider tenantProvider;
015  private final QueryCacheEntryValidate queryCacheEntryValidate;
016
017  public ServerCacheConfig(ServerCacheType type, String cacheKey, String shortName, ServerCacheOptions cacheOptions, CurrentTenantProvider tenantProvider, QueryCacheEntryValidate queryCacheEntryValidate) {
018    this.type = type;
019    this.cacheKey = cacheKey;
020    this.shortName = shortName;
021    this.cacheOptions = cacheOptions;
022    this.tenantProvider = tenantProvider;
023    this.queryCacheEntryValidate = queryCacheEntryValidate;
024  }
025
026  /**
027   * Return the cache type.
028   */
029  public ServerCacheType getType() {
030    return type;
031  }
032
033  /**
034   * Return the name of the cache.
035   */
036  public String getCacheKey() {
037    return cacheKey;
038  }
039
040  /**
041   * Return the short name for the cache.
042   */
043  public String getShortName() {
044    return shortName;
045  }
046
047  /**
048   * Return the tuning options.
049   */
050  public ServerCacheOptions getCacheOptions() {
051    return cacheOptions;
052  }
053
054  /**
055   * Return the current tenant provider.
056   */
057  public CurrentTenantProvider getTenantProvider() {
058    return tenantProvider;
059  }
060
061  /**
062   * Return the service that provides validation for query cache entries.
063   */
064  public QueryCacheEntryValidate getQueryCacheEntryValidate() {
065    return queryCacheEntryValidate;
066  }
067
068  /**
069   * Return true if the cache is a query cache.
070   */
071  public boolean isQueryCache() {
072    return type == ServerCacheType.QUERY;
073  }
074}