aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/session/cache
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-25 14:24:08 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-25 14:24:08 -0700
commitbf0173eb4bac4ab86b43f101eb013051bfc40817 (patch)
tree166beb98c54799a62922762f70be9a9556bb01f0 /src/main/java/org/traccar/session/cache
parent2fcffc5b55f59310d289a21d1ebc2ee6bf15bcd5 (diff)
downloadtrackermap-server-bf0173eb4bac4ab86b43f101eb013051bfc40817.tar.gz
trackermap-server-bf0173eb4bac4ab86b43f101eb013051bfc40817.tar.bz2
trackermap-server-bf0173eb4bac4ab86b43f101eb013051bfc40817.zip
Simplify broadcast calls
Diffstat (limited to 'src/main/java/org/traccar/session/cache')
-rw-r--r--src/main/java/org/traccar/session/cache/CacheManager.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/session/cache/CacheManager.java b/src/main/java/org/traccar/session/cache/CacheManager.java
index d2ada7d43..bc5fc357f 100644
--- a/src/main/java/org/traccar/session/cache/CacheManager.java
+++ b/src/main/java/org/traccar/session/cache/CacheManager.java
@@ -58,6 +58,7 @@ public class CacheManager implements BroadcastInterface {
private final Config config;
private final Storage storage;
+ private final BroadcastService broadcastService;
private final ReadWriteLock lock = new ReentrantReadWriteLock();
@@ -73,9 +74,10 @@ public class CacheManager implements BroadcastInterface {
public CacheManager(Config config, Storage storage, BroadcastService broadcastService) throws StorageException {
this.config = config;
this.storage = storage;
- broadcastService.registerListener(this);
+ this.broadcastService = broadcastService;
invalidateServer();
invalidateUsers();
+ broadcastService.registerListener(this);
}
public Config getConfig() {
@@ -198,6 +200,8 @@ public class CacheManager implements BroadcastInterface {
}
public <T extends BaseModel> void updateOrInvalidate(T object) throws StorageException {
+ broadcastService.invalidateObject(object.getClass(), object.getId());
+
boolean invalidate = false;
var before = getObject(object.getClass(), object.getId());
if (before == null) {
@@ -231,6 +235,8 @@ public class CacheManager implements BroadcastInterface {
public void invalidatePermission(
Class<? extends BaseModel> clazz1, long id1,
Class<? extends BaseModel> clazz2, long id2) {
+ broadcastService.invalidatePermission(clazz1, id1, clazz2, id2);
+
try {
invalidate(new CacheKey(clazz1, id1), new CacheKey(clazz2, id2));
} catch (StorageException e) {