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

Crane4jTemplate 需要提供一个用于直接添加/刷新容器缓存数据的 API #316

Closed
Createsequence opened this issue Jun 27, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@Createsequence
Copy link
Collaborator

对于一些基于本地缓存的数据,比如枚举、常量等,目前是没有办法直接更新数据的,而是需要通过类似下面的代码来更新数据:

// 获取指定的容器
Container<?> container = crane4jTemplate.opsForContainer()
    .getContainer("localCache");
// 将其强转为 LimitedConatnier 后再获取缓存数据的 Map 对象
Map<?, ?> data = ((LimitedConatnier<?>) container).getAll();
// 通过 Map 对象更新数据
data.putAll(xx);

希望能够提供一个独立的 API,用于快速的注册或刷新此类本地缓存数据,比如:

crane4jTemplate.opsForContainer()
    .refreshCacheData(”localCache“, xx); // 直接刷新数据

该 API 应当支持:

  • 如果不存在该容器,则直接使用输入的数据创建并注册一个新容器;
  • 如果容器存在,且为 LimitedContainer,则刷新数据;
  • 如果容器存在,但是不为 LimitedContainer,则报错;

该 API 需要考虑与目前的 Crane4jTemplate 中已有的容器注册机制进行兼容。

@Createsequence Createsequence added the enhancement New feature or request label Jun 27, 2024
@Createsequence Createsequence added this to the release 2.9.0 milestone Jun 27, 2024
@Createsequence Createsequence self-assigned this Jun 27, 2024
Createsequence added a commit that referenced this issue Jun 27, 2024
Createsequence added a commit that referenced this issue Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant