Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.7.8 gm snapshot #942

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion introduce_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,34 @@ Cache<String, Long> orderSumCache = RedisCacheBuilder.createRedisCacheBuilder()
当前支持的缓存系统包括以下4个,而且要支持一种新的缓存也是非常容易的:
* [Caffeine](https://github.com/ben-manes/caffeine)(基于本地内存)
* LinkedHashMap(基于本地内存,JetCache自己实现的简易LRU缓存)
* ConcurrentPatriciaTrieCache (基于本地内存,PatriciaTrie 实现的缓存前缀缓存,可根据前缀删除key)
* Alibaba Tair(相关实现未在Github开源,在阿里内部Gitlab上可以找到)
* Redis(含jedis、lettuce、spring-data、redisson几种访问方式)
* Redis(含jedis、lettuce、spring-data、redisson几种访问方式,新增前缀删除能力)

前缀删除demo
```java

@Cached(name = "cache-name1", key = "#req.tid+'-'+#req.pid + '-'+#request.param1",
localExpire = 900,
cacheType = CacheType.BOTH)
public boolean getSomething01(Request request) {
return true;
}

@Cached(name = "cache-name2", key = "#req.tid+'-'+#req.pid + '-'+#request.param2",
localExpire = 900,
cacheType = CacheType.BOTH)
public boolean getSomething02(Request request) {
return true;
}

@CacheInvalidate(name = "cache-name1", key = "#req.tid+'-'+#req.pid",delByPrefix = true)
@CacheInvalidate(name = "cache-name2", key = "#req.tid+'-'+#req.pid",delByPrefix = true)
public void delSomething(Request req) {}
//delByPrefix = true 代表删除所有以req.tid+'-'+#req.pid为前缀的key

//调用delSomething 时会将cache-name1和cache-name2中以req.tid+'-'+#req.pid为前缀的key全部删除
```


使用JetCache的系统需求:
Expand Down
2 changes: 1 addition & 1 deletion jetcache-anno-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>jetcache-parent</artifactId>
<groupId>com.alicp.jetcache</groupId>
<version>2.7.8-SNAPSHOT</version>
<version>2.7.8-GM-SNAPSHOT</version>
<relativePath>../jetcache-parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,11 @@
* set multi to true indicates jetcache to invalidate each element of the iterable keys.
*/
boolean multi() default CacheConsts.DEFAULT_MULTI;


/**
* If set to true, jetcache will delete all keys with the specified prefix.
* @return
*/
boolean delByPrefix() default false;
}
2 changes: 1 addition & 1 deletion jetcache-anno/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>jetcache-parent</artifactId>
<groupId>com.alicp.jetcache</groupId>
<version>2.7.8-SNAPSHOT</version>
<version>2.7.8-GM-SNAPSHOT</version>
<relativePath>../jetcache-parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ private static CacheInvalidateAnnoConfig createCacheInvalidateAnnoConfig(CacheIn
cc.setCondition(anno.condition());
cc.setMulti(anno.multi());
cc.setDefineMethod(m);
cc.setDelByPrefix(anno.delByPrefix());
return cc;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,15 @@
import com.alicp.jetcache.anno.support.CacheUpdateAnnoConfig;
import com.alicp.jetcache.anno.support.CachedAnnoConfig;
import com.alicp.jetcache.anno.support.ConfigMap;
import com.alicp.jetcache.embedded.ConcurrentPatriciaTrieCache;
import com.alicp.jetcache.event.CacheLoadEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Array;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.function.Supplier;

/**
Expand Down Expand Up @@ -178,8 +173,13 @@ private static void doInvalidate(CacheInvokeContext context, CacheInvalidateAnno
} else {
cache.remove(key);
}
// delByPrefix
if (annoConfig.isDelByPrefix()) {
(cache).delByPrefix(key);
}
}


private static void doUpdate(CacheInvokeContext context, CacheUpdateAnnoConfig updateAnnoConfig) {
Cache cache = context.getCacheFunction().apply(context, updateAnnoConfig);
if (cache == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class CacheAnnoConfig {
private Cache<?, ?> cache;
private Method defineMethod;


public String getArea() {
return area;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,14 @@ public boolean isMulti() {
public void setMulti(boolean multi) {
this.multi = multi;
}

private boolean delByPrefix;

public boolean isDelByPrefix() {
return delByPrefix;
}

public void setDelByPrefix(boolean delByPrefix) {
this.delByPrefix = delByPrefix;
}
}
36 changes: 21 additions & 15 deletions jetcache-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.alicp.jetcache</groupId>
<artifactId>jetcache-bom</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.7.8-GM-SNAPSHOT</version>
<packaging>pom</packaging>

<name>jetcache</name>
Expand Down Expand Up @@ -71,62 +71,62 @@
<dependency>
<groupId>com.alicp.jetcache</groupId>
<artifactId>jetcache-anno</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.7.8-GM-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.alicp.jetcache</groupId>
<artifactId>jetcache-anno-api</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.7.8-GM-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.alicp.jetcache</groupId>
<artifactId>jetcache-core</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.7.8-GM-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.alicp.jetcache</groupId>
<artifactId>jetcache-autoconfigure</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.7.8-GM-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.alicp.jetcache</groupId>
<artifactId>jetcache-starter-redis</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.7.8-GM-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.alicp.jetcache</groupId>
<artifactId>jetcache-starter-redis-lettuce</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.7.8-GM-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.alicp.jetcache</groupId>
<artifactId>jetcache-starter-redis-springdata</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.7.8-GM-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.alicp.jetcache</groupId>
<artifactId>jetcache-starter-redisson</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.7.8-GM-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.alicp.jetcache</groupId>
<artifactId>jetcache-redis</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.7.8-GM-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.alicp.jetcache</groupId>
<artifactId>jetcache-redis-lettuce</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.7.8-GM-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.alicp.jetcache</groupId>
<artifactId>jetcache-redis-springdata</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.7.8-GM-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.alicp.jetcache</groupId>
<artifactId>jetcache-redisson</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.7.8-GM-SNAPSHOT</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -222,6 +222,12 @@
<version>2.9.3</version>
<!--3.0+ need java 11-->
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand All @@ -239,8 +245,8 @@
<version>${build-helper-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<version>${xml-maven-plugin.version}</version>
</plugin>
</plugins>
Expand Down
8 changes: 7 additions & 1 deletion jetcache-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>jetcache-parent</artifactId>
<groupId>com.alicp.jetcache</groupId>
<version>2.7.8-SNAPSHOT</version>
<version>2.7.8-GM-SNAPSHOT</version>
<relativePath>../jetcache-parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -57,5 +57,11 @@
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<optional>true</optional>
</dependency>

</dependencies>
</project>
Loading
Loading