title: How to create cache in Java to store user sessions
body: <p>I want to create cache in java to store user sessions. It's something like a cache which will store for example 5 elements for every user. I need some kind of java data structure which must be able to remember this data. So far I created this Java code:</p>
  
  <pre><code>import java.sql.SQLException;
  import java.util.ArrayList;
  import java.util.List;
  
  public class SessionCache {
  
      public SessionCache() {
      }
  
      /* Create object to store sessions */
      private List&lt;ActiveSessionsObj&gt; dataList = new ArrayList&lt;&gt;();
  
      public static class ActiveSessionsObj {
          private int one;
          private int two;
          private int three;
          private int four;
          private int five;
  
          private ActiveSessionsObj(int one, int two, int three, int four, int five) {
              throw new UnsupportedOperationException("Not yet implemented");
          }
      }
  
      public List&lt;ActiveSessionsObj&gt; addCache(int one, int two, int three, int four, int five){
  
          dataList.add(new ActiveSessionsObj(
                          one,
                          two,
                          three,
                          four,
                          five));
            return dataList;    
      }   
  
  }
  </code></pre>
  
  <p>I'm new to java and I need a help how I can add data to the structure and how I can remove data from the structure. I need to do this using a key. Is this possible? Or is there more appropriate data structure to store the data according to mu needs?</p>
  
  <p>Best wishes</p>