Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 1.08 KB  |  views: 30  |  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.  
  2. import java.util.HashMap;
  3. import java.util.Map;
  4.  
  5. public class SessionCache {
  6.  
  7.     public SessionCache() {
  8.     }
  9.     /*
  10.      * Create object to store sessions
  11.      */
  12.     Map<String, ActiveSessionsObj> cache = new HashMap<String, ActiveSessionsObj>();
  13.  
  14.     public static class ActiveSessionsObj {
  15.  
  16.         public ActiveSessionsObj(int one, int two, int three, int four, int five) {
  17.            
  18.         }
  19.     }
  20.  
  21.     public void addCache(String user_id, int one, int two, int three, int four, int five) {
  22.         // You may want to check if an entry already exists for a user,
  23.         // depends on logic in your application. Otherwise, this will
  24.         // replace any previous entry for 'user_id'.
  25.         cache.put(user_id, new ActiveSessionsObj(one, two, three, four, five));
  26.     }
  27.    
  28.     public Object getCache(String user_id){
  29.        
  30.         return cache.get(user_id);
  31.     }
  32.    
  33.     public void removeCache(String user_id){
  34.        
  35.         cache.remove(user_id);
  36.     }
  37.    
  38.     public void flushCache(){
  39.        
  40.         cache.clear();
  41.     }
  42.    
  43. }
clone this paste RAW Paste Data