chore: 导入后端 s-file(alita-bjy-uygur, f分支)至 backend/

This commit is contained in:
2026-11-01 20:34:00 +08:00
parent 4c7dd207d0
commit 20b2dd7009
1637 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
package com.senmesh.common.cache;
import java.util.Map;
import org.apache.commons.collections.MapUtils;
import com.google.common.collect.Maps;
/**
* @author sr on 2020-07-07
*/
public class DefaultCacheProvider implements ICacheProvider {
private Map<String, Long> numLimitMap = Maps.newConcurrentMap();
@Override
public boolean outLimit(final String key, Long maxNumLimit) {
Long currentNumLimit = null;
final Object lockKey = key.intern();
synchronized (lockKey) {
currentNumLimit = MapUtils.getLong(numLimitMap, key, 0L);
if (currentNumLimit >= maxNumLimit) {
return true;
}
currentNumLimit++;
numLimitMap.put(key, currentNumLimit);
}
return false;
}
}