Skip to content

Commit 39a257c

Browse files
authored
Merge pull request #427 from netgrif/NAE-2400
[NAE-2400] Prevent Caching of Null Results in Process Cache
2 parents 844d184 + dfc012f commit 39a257c

9 files changed

Lines changed: 22 additions & 8 deletions

File tree

application-engine/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.netgrif</groupId>
88
<artifactId>application-engine-parent</artifactId>
9-
<version>7.0.0-RC10.1</version>
9+
<version>7.0.0-RC10.2</version>
1010
</parent>
1111

1212
<artifactId>application-engine</artifactId>

application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,15 @@ public void evictAllCaches() {
138138
requireNonNull(cacheManager.getCache(cacheProperties.getPetriNetByIdentifier()), cacheProperties.getPetriNetByIdentifier()).clear();
139139
}
140140

141+
@Override
142+
public void evictCache(String id, String identifier, String version) {
143+
requireNonNull(cacheManager.getCache(cacheProperties.getPetriNetById()), cacheProperties.getPetriNetById()).evict(id);
144+
requireNonNull(cacheManager.getCache(cacheProperties.getPetriNetDefault()), cacheProperties.getPetriNetDefault()).evict(identifier);
145+
requireNonNull(cacheManager.getCache(cacheProperties.getPetriNetLatest()), cacheProperties.getPetriNetLatest()).evict(identifier);
146+
requireNonNull(cacheManager.getCache(cacheProperties.getPetriNetCache()), cacheProperties.getPetriNetCache()).evict(new ObjectId(id));
147+
requireNonNull(cacheManager.getCache(cacheProperties.getPetriNetByIdentifier()), cacheProperties.getPetriNetByIdentifier()).evict(identifier + version);
148+
}
149+
141150
public void evictCache(PetriNet net) {
142151
requireNonNull(cacheManager.getCache(cacheProperties.getPetriNetById()), cacheProperties.getPetriNetById()).evict(net.getStringId());
143152
requireNonNull(cacheManager.getCache(cacheProperties.getPetriNetDefault()), cacheProperties.getPetriNetDefault()).evict(net.getIdentifier());
@@ -150,7 +159,7 @@ public void evictCache(PetriNet net) {
150159
* Get read only Petri net.
151160
*/
152161
@Override
153-
@Cacheable(value = "petriNetCache")
162+
@Cacheable(value = "petriNetCache", unless = "#result == null")
154163
public PetriNet get(ObjectId petriNetId) {
155164
Optional<PetriNet> optional = repository.findById(petriNetId.toString());
156165
if (optional.isEmpty()) {
@@ -301,7 +310,7 @@ protected final Optional<PetriNet> doSaveInternal(PetriNet petriNet) {
301310
}
302311

303312
@Override
304-
@Cacheable(value = "petriNetById")
313+
@Cacheable(value = "petriNetById", unless = "#result == null")
305314
public PetriNet getPetriNet(String id) {
306315
Optional<PetriNet> net = repository.findById(id);
307316
if (net.isEmpty()) {

application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/interfaces/IPetriNetService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ ImportPetriNetEventOutcome importPetriNet(ImportPetriNetParams importPetriNetPar
257257
*/
258258
void evictAllCaches();
259259

260+
void evictCache(String id, String identifier, String version);
261+
260262
/**
261263
* Evicts the cache for the given {@link PetriNet}.
262264
*

application-engine/src/main/java/com/netgrif/application/engine/workflow/service/FieldActionsCacheService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ public void cachePetriNetFunctions(PetriNet petriNet) {
5454
return;
5555
}
5656

57+
log.info("Caching functions for PetriNet id={}", petriNet.getIdentifier());
58+
5759
List<CachedFunction> functions = petriNet.getFunctions(FunctionScope.GLOBAL).stream()
5860
.map(function -> CachedFunction.build(shell, function))
5961
.collect(Collectors.toList());
@@ -66,6 +68,7 @@ public void cachePetriNetFunctions(PetriNet petriNet) {
6668
} else {
6769
globalFunctionsCache.evictIfPresent(petriNet.getIdentifier());
6870
}
71+
log.info("Finished caching functions for PetriNet id={}", petriNet.getIdentifier());
6972
}
7073

7174
@Override

nae-object-library/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.netgrif</groupId>
99
<artifactId>application-engine-parent</artifactId>
10-
<version>7.0.0-RC10.1</version>
10+
<version>7.0.0-RC10.2</version>
1111
</parent>
1212

1313
<artifactId>nae-object-library</artifactId>

nae-spring-core-adapter/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.netgrif</groupId>
99
<artifactId>application-engine-parent</artifactId>
10-
<version>7.0.0-RC10.1</version>
10+
<version>7.0.0-RC10.2</version>
1111
</parent>
1212

1313
<artifactId>nae-spring-core-adapter</artifactId>

nae-user-ce/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.netgrif</groupId>
88
<artifactId>application-engine-parent</artifactId>
9-
<version>7.0.0-RC10.1</version>
9+
<version>7.0.0-RC10.2</version>
1010
</parent>
1111

1212
<artifactId>nae-user-ce</artifactId>

nae-user-common/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.netgrif</groupId>
88
<artifactId>application-engine-parent</artifactId>
9-
<version>7.0.0-RC10.1</version>
9+
<version>7.0.0-RC10.2</version>
1010
</parent>
1111

1212
<artifactId>nae-user-common</artifactId>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.netgrif</groupId>
88
<artifactId>application-engine-parent</artifactId>
9-
<version>7.0.0-RC10.1</version>
9+
<version>7.0.0-RC10.2</version>
1010
<packaging>pom</packaging>
1111

1212
<name>NETGRIF Application Engine parent</name>

0 commit comments

Comments
 (0)