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

是否支持 @CacheInvalidate 根据name删除 #947

Open
zb315044652 opened this issue Nov 25, 2024 · 0 comments
Open

是否支持 @CacheInvalidate 根据name删除 #947

zb315044652 opened this issue Nov 25, 2024 · 0 comments

Comments

@zb315044652
Copy link

zb315044652 commented Nov 25, 2024

@Mapper
public interface UserMapper {

    @CacheInvalidate(name = "UserMapper:", key = "#args[0]")
    int deleteByPrimaryKey(Long id);

    @CacheInvalidate(name = "UserMapper:", key = "*")
    int insertSelective(UserDO record);

    @Cached(name = "UserMapper:", key = "args[0]", expire = 3600, localExpire = 3500, timeUnit = TimeUnit.SECONDS, cacheType = CacheType.BOTH)
    UserDO selectByPrimaryKey(Long id);

    @CacheUpdate(name = "UserMapper:", key = "args[0].id", value = "args[0]")
    int updateByPrimaryKeySelective(UserDO record);

    @CacheUpdate(name = "UserMapper:", key = "args[0].id", value = "args[0]")
    int updateByPrimaryKey(UserDO record);

    int batchInsert(@Param("list") List<UserDO> list);

    @Cached(name = "UserMapper:", key = "'status:' + args[0]", expire = 3600, localExpire = 3500, timeUnit = TimeUnit.SECONDS, cacheType = CacheType.BOTH)
    List<UserDO> selectByStatus(Integer status);

    List<UserDO> selectAll();
}

在这种使用场景下,不仅要根据ID做缓存,还需要根据某个状态status做缓存,为了保证数据正确性,在新增的时候需要清理缓存,需要根据 @CacheInvalidate(name = "UserMapper:") 进行清理全部名称前缀为UserMapper:的缓存,是否支持这样的功能?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant