Commit d5b2b3a9055bd6a2606d9ccd4c6757394473c56f
1 parent
4a52d215
#fix:修复L1级cache使用@CacheEvict(allEntries = true)不生效的bug
Showing
1 changed file
with
15 additions
and
2 deletions
src/main/java/com/irrigation/icl/cache/core/LayeringCache.java
| ... | ... | @@ -116,13 +116,26 @@ public class LayeringCache extends RedisCache { |
| 116 | 116 | return wrapper; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | + @Override | |
| 120 | + public void clear() { | |
| 121 | + super.clear(); | |
| 122 | + if (layerL1Enable) { | |
| 123 | + Ehcache ehCache = getL1Cache(super.getName()); | |
| 124 | + ehCache.removeAll(); | |
| 125 | + layeringCacheManager.publishMessage(Command.rem(this.ID, super.getName())); | |
| 126 | + } | |
| 127 | + } | |
| 128 | + | |
| 119 | 129 | public void updateL1Cache(Command command) { |
| 120 | 130 | if (layerL1Enable && command != null && !this.ID.equals(command.getSrc())) { |
| 121 | 131 | switch (command.getOper()) { |
| 122 | 132 | case Command.OPT_DEL: |
| 123 | - case Command.OPT_REM: | |
| 124 | 133 | getL1Cache(command.getName()).remove(command.getKey()); |
| 125 | - log.info("Clear Cache L1 {} - {}", command.getName(), command.getKey()); | |
| 134 | + log.info("Remove Cache L1 {} - {}", command.getName(), command.getKey()); | |
| 135 | + break; | |
| 136 | + case Command.OPT_REM: | |
| 137 | + getL1Cache(command.getName()).removeAll(); | |
| 138 | + log.info("Clear Cache L1 {}", command.getName()); | |
| 126 | 139 | break; |
| 127 | 140 | case Command.OPT_SET: |
| 128 | 141 | Cache.ValueWrapper wrapper = super.get(command.getKey()); | ... | ... |