/** * Copyright (c) 2013-2021 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.ruoyi.common.redis.manager; import org.ruoyi.common.redis.utils.RedisUtils; import org.redisson.api.RMap; import org.redisson.api.RMapCache; import org.redisson.spring.cache.CacheConfig; import org.redisson.spring.cache.RedissonCache; import org.springframework.boot.convert.DurationStyle; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; import org.springframework.cache.transaction.TransactionAwareCacheDecorator; import org.springframework.util.StringUtils; import java.util.Collection; import java.util.Collections; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; /** * A {@link CacheManager} implementation * backed by Redisson instance. *
* 修改 RedissonSpringCacheManager 源码
* 重写 cacheName 处理方法 支持多参数
*
* @author Nikita Koksharov
*
*/
@SuppressWarnings("unchecked")
public class PlusSpringCacheManager implements CacheManager {
private boolean dynamic = true;
private boolean allowNullValues = true;
private boolean transactionAware = true;
Map
* Default is
* Default is
* `null` parameter setups dynamic mode
*
* @param names of caches
*/
public void setCacheNames(Collectiontrue
*
* @param allowNullValues stores if true
*/
public void setAllowNullValues(boolean allowNullValues) {
this.allowNullValues = allowNullValues;
}
/**
* Defines if cache aware of Spring-managed transactions.
* If {@code true} put/evict operations are executed only for successful transaction in after-commit phase.
* false
*
* @param transactionAware cache is transaction aware if true
*/
public void setTransactionAware(boolean transactionAware) {
this.transactionAware = transactionAware;
}
/**
* Defines 'fixed' cache names.
* A new cache instance will not be created in dynamic for non-defined names.
*