From b1c20256cc7b28a80eafb8edfa1e000dbc61b4e1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 9 Sep 2014 21:25:55 +0200 Subject: [PATCH] Store albums and images per-Sone in database. --- .../java/net/pterodactylus/sone/database/memory/MemoryDatabase.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java b/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java index 237d321..cd3be84 100644 --- a/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java +++ b/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java @@ -114,8 +114,10 @@ public class MemoryDatabase extends AbstractService implements Database { private final Set knownPostReplies = new HashSet(); private final Map allAlbums = new HashMap(); + private final Multimap soneAlbums = HashMultimap.create(); private final Map allImages = new HashMap(); + private final Multimap soneImages = HashMultimap.create(); /** * Creates a new memory database. @@ -447,6 +449,7 @@ public class MemoryDatabase extends AbstractService implements Database { lock.writeLock().lock(); try { allAlbums.put(album.getId(), album); + soneAlbums.put(album.getSone().getId(), album); } finally { lock.writeLock().unlock(); } @@ -457,6 +460,7 @@ public class MemoryDatabase extends AbstractService implements Database { lock.writeLock().lock(); try { allAlbums.remove(album.getId()); + soneAlbums.remove(album.getSone().getId(), album); } finally { lock.writeLock().unlock(); } @@ -494,6 +498,7 @@ public class MemoryDatabase extends AbstractService implements Database { lock.writeLock().lock(); try { allImages.put(image.getId(), image); + soneImages.put(image.getSone().getId(), image); } finally { lock.writeLock().unlock(); } @@ -504,6 +509,7 @@ public class MemoryDatabase extends AbstractService implements Database { lock.writeLock().lock(); try { allImages.remove(image.getId()); + soneImages.remove(image.getSone().getId(), image); } finally { lock.writeLock().unlock(); } -- 2.7.4