Advertisement
Guest User

Untitled

a guest
May 1st, 2012
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement