From: David ‘Bombe’ Roden Date: Tue, 9 Sep 2014 19:25:55 +0000 (+0200) Subject: Store albums and images per-Sone in database. X-Git-Tag: 0.9-rc1^2~3^2~135 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=b1c20256cc7b28a80eafb8edfa1e000dbc61b4e1;p=Sone.git Store albums and images per-Sone in database. --- 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(); }