diff options
author | Anton Tananaev <anton@traccar.org> | 2022-06-02 17:38:12 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-06-02 17:38:12 -0700 |
commit | 43942f459f456b05c62ea7549123e28fd7560d56 (patch) | |
tree | aae5faad77ce2977346bce5c0517069d47f8041d /src/main/java/org/traccar | |
parent | 946b0ebb443aaeb27bcc0e736eda8e929da8738c (diff) | |
download | trackermap-server-43942f459f456b05c62ea7549123e28fd7560d56.tar.gz trackermap-server-43942f459f456b05c62ea7549123e28fd7560d56.tar.bz2 trackermap-server-43942f459f456b05c62ea7549123e28fd7560d56.zip |
Inverse user notification cache
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r-- | src/main/java/org/traccar/session/cache/CacheManager.java | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/main/java/org/traccar/session/cache/CacheManager.java b/src/main/java/org/traccar/session/cache/CacheManager.java index d019b072b..f6f04cc36 100644 --- a/src/main/java/org/traccar/session/cache/CacheManager.java +++ b/src/main/java/org/traccar/session/cache/CacheManager.java @@ -59,7 +59,7 @@ public class CacheManager { private final Map<CacheKey, CacheValue> deviceCache = new HashMap<>(); private final Map<Long, Map<Class<? extends BaseModel>, List<Long>>> deviceLinks = new HashMap<>(); - private final Map<Long, List<Notification>> userNotifications = new HashMap<>(); + private final Map<Long, List<User>> notificationUsers = new HashMap<>(); @Inject public CacheManager(Storage storage) throws StorageException { @@ -87,10 +87,10 @@ public class CacheManager { } } - public List<Notification> getUserNotifications(long userId) { + public List<User> getNotificationUsers(long notificationId) { try { lock.readLock().lock(); - return userNotifications.get(userId); + return notificationUsers.get(notificationId); } finally { lock.readLock().unlock(); } @@ -130,13 +130,13 @@ public class CacheManager { } private void invalidateUsers() throws StorageException { - Map<Long, Notification> notifications = new HashMap<>(); - storage.getObjects(Notification.class, new Request(new Columns.All())) - .forEach(notification -> notifications.put(notification.getId(), notification)); + Map<Long, User> users = new HashMap<>(); + storage.getObjects(User.class, new Request(new Columns.All())) + .forEach(user -> users.put(user.getId(), user)); storage.getPermissions(User.class, Notification.class).forEach(permission -> { - long userId = permission.getOwnerId(); - var notification = notifications.get(permission.getPropertyId()); - userNotifications.computeIfAbsent(userId, k -> new LinkedList<>()).add(notification); + long notificationId = permission.getPropertyId();; + var user = users.get(permission.getOwnerId()); + notificationUsers.computeIfAbsent(notificationId, k -> new LinkedList<>()).add(user); }); } |