title: in-memory storing and working with large data lists Spring Boot 2 java
body: <p>I have an application which does a lot of work with large in-memory data lists. Currently i use a singleton datacache structure as follows:</p>
  
  <pre><code>public class DataCache {
  
      private final Map&lt;String, Map&lt;String, ArrayList&lt;String&gt;&gt;&gt; arraysMap = new HashMap();
      private final Map&lt;String, Map&lt;String, Integer&gt;&gt; integerMap = new HashMap();
      private final Map&lt;String, Map&lt;String, String&gt;&gt; stringMap = new HashMap();
      private final Map&lt;String, Map&lt;String, MyObject&gt;&gt; arraysMap = new HashMap();
  
      /**
       * Map for boolean locks used to temporaly disable
       * edition while the data changes.
       */
      private final Map&lt;String, Map&lt;String, Boolean&gt;&gt; locksMap = new HashMap();
  
      private DataCache() {
  
      }
  
      private static final DataCache dataCache = new DataCache();
  
      public static DataCache getInstanceOf() {
  
          return dataCache;
      }
  
      ...getters/setters...
  }
  </code></pre>
  
  <p>the <code>arraysMap</code> and <code>myObjectMap</code> are getting the majority of workload - something about 20-50/s list operations such as <code>put</code>/<code>replace</code>/<code>delete</code> and similar for the <code>myObjectMap</code> (sum for all objects). <code>maps</code> are accessed in multi-threaded context. Initially the this kind of load wasn't expected, but it seems to be working just fine. 
  However, it seems like the the data complexity will grow as well as the load. </p>
  
  <p><strong>Question</strong> is - is it reasonable to switch to some external solution (<code>redis</code>?) or keeping this improvisation might be sufficient. The load might increase to max 500/s operations per map. Lists in <code>arraysMap</code> can be as big as 200mb.</p>