From cc05c6e1cc02b788f52b704e65bae48f917c7be6 Mon Sep 17 00:00:00 2001
From: Christoph Thelen <christoph.thelen@mni.thm.de>
Date: Mon, 1 Jun 2015 13:03:04 +0200
Subject: [PATCH] Add "note to developers" regarding caching

---
 src/main/java/de/thm/arsnova/dao/CouchDBDao.java | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/main/java/de/thm/arsnova/dao/CouchDBDao.java b/src/main/java/de/thm/arsnova/dao/CouchDBDao.java
index aadd3d1e7..fe956fbcf 100644
--- a/src/main/java/de/thm/arsnova/dao/CouchDBDao.java
+++ b/src/main/java/de/thm/arsnova/dao/CouchDBDao.java
@@ -84,6 +84,21 @@ import de.thm.arsnova.services.ISessionService;
 
 /**
  * Database implementation based on CouchDB.
+ *
+ * Note to developers:
+ *
+ * This class makes use of Spring Framework's caching annotations. When you are about to add new functionality,
+ * you should also think about the possibility of caching. Ideally, your methods should be dependent on domain
+ * objects like Session or Question, which can be used as cache keys. Relying on plain String objects as a key, e.g.
+ * by passing only a Session's keyword, will make your cache annotations less readable. You will also need to think
+ * about cases where your cache needs to be updated and evicted.
+ *
+ * In order to use cached methods from within this object, you have to use the getDatabaseDao() method instead of
+ * using the "this" pointer. This is because caching is only available if the method is called through a Spring Proxy,
+ * which is not the case when using "this".
+ *
+ * @see <a href="http://docs.spring.io/spring/docs/current/spring-framework-reference/html/cache.html">Spring Framework's Cache Abstraction</a>
+ * @see <a href="https://github.com/thm-projects/arsnova-backend/wiki/Caching">Caching in ARSnova explained</a>
  */
 @Component("databaseDao")
 public class CouchDBDao implements IDatabaseDao, ApplicationEventPublisherAware {
-- 
GitLab