Tabnine Logo
J2CacheConfig
Code IndexAdd Tabnine to your IDE (free)

How to use
J2CacheConfig
in
net.oschina.j2cache

Best Java code snippets using net.oschina.j2cache.J2CacheConfig (Showing top 7 results out of 315)

origin: sanluan/PublicCMS

@Override
public void init(String region, Properties properties) {
  this.region = region;
  J2CacheConfig config = new J2CacheConfig();
  config.setSerialization(properties.getProperty("j2cache.serialization"));
  config.setBroadcast(properties.getProperty("j2cache.broadcast"));
  config.setL1CacheName(properties.getProperty("j2cache.L1.provider_class"));
  config.setL2CacheName(properties.getProperty("j2cache.L2.provider_class"));
  config.setSyncTtlToRedis(!"false".equalsIgnoreCase(properties.getProperty("j2cache.sync_ttl_to_redis")));
  config.setDefaultCacheNullObject("true".equalsIgnoreCase(properties.getProperty("j2cache.default_cache_null_object")));
  String l2_config_section = properties.getProperty("j2cache.L2.config_section");
  if (l2_config_section == null || l2_config_section.trim().equals("")) {
    l2_config_section = config.getL2CacheName();
  }
  final String l2_section = l2_config_section;
  properties.forEach((k, v) -> {
    String key = (String) k;
    if (key.startsWith(config.getBroadcast() + ".")) {
      config.getBroadcastProperties().setProperty(key.substring((config.getBroadcast() + ".").length()), (String) v);
    }
    if (key.startsWith(config.getL1CacheName() + ".")) {
      config.getL1CacheProperties().setProperty(key.substring((config.getL1CacheName() + ".").length()), (String) v);
    }
    if (key.startsWith(l2_section + ".")) {
      config.getL2CacheProperties().setProperty(key.substring((l2_section + ".").length()), (String) v);
    }
  });
  J2CacheBuilder builder = J2CacheBuilder.init(config);
  channel = builder.getChannel();
}
origin: nutzam/nutzboot

J2CacheConfig j2CacheConfig = new J2CacheConfig();
j2CacheConfig.setBroadcast(nb_broadcast);
j2CacheConfig.setBroadcastProperties(nb_broadcastProperties);
j2CacheConfig.setL1CacheName(nb_l1CacheName);
j2CacheConfig.setL1CacheProperties(nb_l1CacheProperties);
j2CacheConfig.setSerialization(nb_serialization);
j2CacheConfig.setL2CacheName(nb_l2CacheName);
j2CacheConfig.setL2CacheProperties(nb_l2CacheProperties);
j2CacheConfig.setSyncTtlToRedis(Boolean.parseBoolean(nb_syncTtlToRedis));
origin: net.oschina.j2cache/j2cache-core

/**
 * Initialize Cache Provider
 *
 * @param config   j2cache config instance
 * @param listener cache listener
 * @return holder : return CacheProviderHolder instance
 */
public static CacheProviderHolder init(J2CacheConfig config, CacheExpiredListener listener) {
  CacheProviderHolder holder = new CacheProviderHolder();
  holder.listener = listener;
  holder.l1_provider = loadProviderInstance(config.getL1CacheName());
  if (!holder.l1_provider.isLevel(CacheObject.LEVEL_1))
    throw new CacheException(holder.l1_provider.getClass().getName() + " is not level_1 cache provider");
  holder.l1_provider.start(config.getL1CacheProperties());
  log.info("Using L1 CacheProvider : {}", holder.l1_provider.getClass().getName());
  holder.l2_provider = loadProviderInstance(config.getL2CacheName());
  if (!holder.l2_provider.isLevel(CacheObject.LEVEL_2))
    throw new CacheException(holder.l2_provider.getClass().getName() + " is not level_2 cache provider");
  holder.l2_provider.start(config.getL2CacheProperties());
  log.info("Using L2 CacheProvider : {}", holder.l2_provider.getClass().getName());
  return holder;
}
origin: yuboon/Aooms

String l2CacheName = j2CacheConfig.getL2CacheName();
if("none".equalsIgnoreCase(l2CacheName)){
  return new LettuceConnectionFactory();
Properties l2CacheProperties = j2CacheConfig.getL2CacheProperties();
String hosts = l2CacheProperties.getProperty("hosts");
String mode = l2CacheProperties.getProperty("mode");
origin: net.oschina.j2cache/j2cache-core

/**
 * 加载配置
 *
 * @return
 * @throws IOException
 */
private void initFromConfig(J2CacheConfig config) {
  SerializationUtils.init(config.getSerialization(), config.getSubProperties(config.getSerialization()));
  //初始化两级的缓存管理
  this.holder = CacheProviderHolder.init(config, (region, key) -> {
    //当一级缓存中的对象失效时,自动清除二级缓存中的数据
    Level2Cache level2 = this.holder.getLevel2Cache(region);
    level2.evict(key);
    if (!level2.supportTTL()) {
      //再一次清除一级缓存是为了避免缓存失效时再次从 L2 获取到值
      this.holder.getLevel1Cache(region).evict(key);
    }
    log.debug("Level 1 cache object expired, evict level 2 cache object [{},{}]", region, key);
    if (policy != null)
      policy.sendEvictCmd(region, key);
  });
  policy = ClusterPolicyFactory.init(holder, config.getBroadcast(), config.getBroadcastProperties());
  log.info("Using cluster policy : {}", policy.getClass().getName());
}
origin: net.oschina.j2cache/j2cache-core

/**
 * Read configuration from input stream
 * @param stream config stream
 */
public final static J2CacheConfig initFromConfig(InputStream stream) throws IOException {
  J2CacheConfig config = new J2CacheConfig();
  config.properties.load(stream);
  config.serialization = trim(config.properties.getProperty("j2cache.serialization"));
  config.broadcast = trim(config.properties.getProperty("j2cache.broadcast"));
  config.l1CacheName = trim(config.properties.getProperty("j2cache.L1.provider_class"));
  config.l2CacheName = trim(config.properties.getProperty("j2cache.L2.provider_class"));
  config.syncTtlToRedis = !"false".equalsIgnoreCase(trim(config.properties.getProperty("j2cache.sync_ttl_to_redis")));
  config.defaultCacheNullObject = "true".equalsIgnoreCase(trim(config.properties.getProperty("j2cache.default_cache_null_object")));
  String l2_config_section = trim(config.properties.getProperty("j2cache.L2.config_section"));
  if (l2_config_section == null || l2_config_section.trim().equals(""))
    l2_config_section = config.l2CacheName;
  config.broadcastProperties = config.getSubProperties(config.broadcast);
  config.l1CacheProperties = config.getSubProperties(config.l1CacheName);
  config.l2CacheProperties = config.getSubProperties(l2_config_section);
  return config;
}
origin: yuboon/Aooms

public JedisConnectionFactory jedisConnectionFactory(net.oschina.j2cache.J2CacheConfig j2CacheConfig) {
  String l2CacheName = j2CacheConfig.getL2CacheName();
  if("none".equalsIgnoreCase(l2CacheName)){
    return new JedisConnectionFactory();
  Properties l2CacheProperties = j2CacheConfig.getL2CacheProperties();
  String hosts = l2CacheProperties.getProperty("hosts");
  String mode = l2CacheProperties.getProperty("mode");
net.oschina.j2cacheJ2CacheConfig

Javadoc

J2Cache configurations

Most used methods

  • <init>
  • getL2CacheName
  • getL2CacheProperties
  • getBroadcast
  • getBroadcastProperties
  • getL1CacheName
  • getL1CacheProperties
  • setBroadcast
  • setL1CacheName
  • setL2CacheName
  • setSerialization
  • setSyncTtlToRedis
  • setSerialization,
  • setSyncTtlToRedis,
  • getConfigStream,
  • getSerialization,
  • getSubProperties,
  • initFromConfig,
  • isDefaultCacheNullObject,
  • isSyncTtlToRedis,
  • setBroadcastProperties,
  • setDefaultCacheNullObject

Popular in Java

  • Making http requests using okhttp
  • notifyDataSetChanged (ArrayAdapter)
  • setScale (BigDecimal)
  • setContentView (Activity)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now