001/** 002 * Copyright (c) 2015-2022, Michael Yang 杨福海 (fuhai999@gmail.com). 003 * <p> 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * <p> 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * <p> 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package io.jboot.components.cache; 017 018 019import com.google.common.collect.Sets; 020import io.jboot.Jboot; 021import io.jboot.app.config.annotation.ConfigModel; 022 023import java.util.Set; 024 025 026@ConfigModel(prefix = "jboot.cache") 027public class JbootCacheConfig { 028 029 public static final String TYPE_EHCACHE = "ehcache"; 030 public static final String TYPE_REDIS = "redis"; 031 public static final String TYPE_EHREDIS = "ehredis"; 032 public static final String TYPE_J2CACHE = "j2cache"; 033 public static final String TYPE_CAFFEINE = "caffeine"; 034 public static final String TYPE_CAREDIS = "caredis"; 035 public static final String TYPE_NONE = "none"; 036 037 public static final Set<String> TYPES = Sets.newHashSet(TYPE_EHCACHE, TYPE_REDIS, TYPE_EHREDIS 038 , TYPE_J2CACHE, TYPE_CAFFEINE, TYPE_CAREDIS, TYPE_NONE); 039 040 private String name = "default"; 041 private String type = TYPE_CAFFEINE; 042 private String typeName; 043 044 private String defaultCachePrefix; 045 private Boolean devMode = false; 046 047 //只启用一级缓存,针对分布式场景下,redis 有关闭了 scan keys 等指令的时候 048 //可以使用 redis 的消息机制做缓存同步 049 private boolean useFirstLevelOnly = false; 050 051 private String cacheSyncMqChannel; 052 053 054 public String getName() { 055 return name; 056 } 057 058 public void setName(String name) { 059 this.name = name; 060 } 061 062 063 public String getType() { 064 return type; 065 } 066 067 public void setType(String type) { 068 this.type = type; 069 } 070 071 public String getTypeName() { 072 return typeName; 073 } 074 075 public void setTypeName(String typeName) { 076 this.typeName = typeName; 077 } 078 079 public String getDefaultCachePrefix() { 080 return defaultCachePrefix; 081 } 082 083 public void setDefaultCachePrefix(String defaultCachePrefix) { 084 this.defaultCachePrefix = defaultCachePrefix; 085 } 086 087 public boolean isDevMode() { 088 return devMode == null ? Jboot.isDevMode() : devMode; 089 } 090 091 public void setDevMode(Boolean devMode) { 092 this.devMode = devMode; 093 } 094 095 public boolean isUseFirstLevelOnly() { 096 return useFirstLevelOnly; 097 } 098 099 public void setUseFirstLevelOnly(boolean useFirstLevelOnly) { 100 this.useFirstLevelOnly = useFirstLevelOnly; 101 } 102 103 public String getCacheSyncMqChannel() { 104 return cacheSyncMqChannel; 105 } 106 107 public void setCacheSyncMqChannel(String cacheSyncMqChannel) { 108 this.cacheSyncMqChannel = cacheSyncMqChannel; 109 } 110}