CON-36 Implementation Plan

use cache<long, token> and multimap<user, long>. Use the removalListener on the cache to go through the map and remove the appropriate

class AccessTokenManager {
	// Have a background thread that runs periodically to cleanup. Do granular locking on tokens.
 
	void cleanup(){
		- remove all timestamps from connections that are older than 24 hours
		- iterate through all the timestamps that got removed
	}
 
 
	Multimap<User, Timestamp> sessions
	Cache<Timestamp, Token> connections //sorted cache with removal listener
 
	public boolean isValidToken(token){
		if(connections.contains(token.getTimestamp()){
			if(token.getTimestamp() is less than 24 hours){
				return true;
			}
			else{
				deleteToken(token)
			}
		}
		return false;
	}
 
	public void deleteToken(token){
		connections.remove(token.getTimestamp());
	}
 
	public void deleteAllTokens(user){
		Set<Timestamp> timestamps = sessions.get(user);
		sessions.remove(user);
		for(timestamp : timestamps){
			connections.remove(timestamp);
		}
	}
 
	public void addToken(user){
		long timestamp = Time.now();
		sessions.put(user, timestamp);
		connections.put(timestamp, AccessToken.create("blah", timestamp)
	}
}