Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 1.07 KB  |  views: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.util.HashMap;
  2. import java.util.Map;
  3.  
  4. public class SessionCache {
  5.  
  6.     public SessionCache() {
  7.     }
  8.     /*
  9.      * Create object to store sessions
  10.      */
  11.     Map<String, ActiveSessionsObj> cache = new HashMap<String, ActiveSessionsObj>();
  12.  
  13.     public static class ActiveSessionsObj {
  14.  
  15.         public ActiveSessionsObj(int one, int two, int three, int four, int five) {
  16.            
  17.         }
  18.     }
  19.  
  20.     public void addCache(String user_id, int one, int two, int three, int four, int five) {
  21.         // You may want to check if an entry already exists for a user,
  22.         // depends on logic in your application. Otherwise, this will
  23.         // replace any previous entry for 'user_id'.
  24.         cache.put(user_id, new ActiveSessionsObj(one, two, three, four, five));
  25.     }
  26.    
  27.     public Object getCache(String user_id){
  28.        
  29.         return cache.get(user_id);
  30.     }
  31.    
  32.     public void removeCache(String user_id){
  33.        
  34.         cache.remove(user_id);
  35.     }
  36.    
  37.     public void flushCache(){
  38.        
  39.         cache.clear();
  40.     }
  41.    
  42. }