Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.HashMap;
- import java.util.Map;
- public class SessionCache {
- public SessionCache() {
- }
- /*
- * Create object to store sessions
- */
- Map<String, ActiveSessionsObj> cache = new HashMap<String, ActiveSessionsObj>();
- public static class ActiveSessionsObj {
- public ActiveSessionsObj(int one, int two, int three, int four, int five) {
- }
- }
- public void addCache(String user_id, int one, int two, int three, int four, int five) {
- // You may want to check if an entry already exists for a user,
- // depends on logic in your application. Otherwise, this will
- // replace any previous entry for 'user_id'.
- cache.put(user_id, new ActiveSessionsObj(one, two, three, four, five));
- }
- public Object getCache(String user_id){
- return cache.get(user_id);
- }
- public void removeCache(String user_id){
- cache.remove(user_id);
- }
- public void flushCache(){
- cache.clear();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement