Advertisement
Guest User

Untitled

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