All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.geso.avans.session.HashMapSessionStore Maven / Gradle / Ivy

package me.geso.avans.session;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

import lombok.ToString;

/**
 * In memory hash session storage for testing/debugging.
 * Do not use in production environment.
 * 
 * @author tokuhirom
 *
 */
@ToString
public class HashMapSessionStore implements WebSessionStore {
	private final Map> storage = new HashMap<>();

	@Override
	public void save(final String sessionId, final Map data) {
		this.storage.put(sessionId, data);
	}

	@Override
	public Optional> load(final String sessionId) {
		final Map map = this.storage.get(sessionId);
		if (map == null) {
			return Optional.empty();
		} else {
			return Optional.of(map);
		}
	}

	@Override
	public void remove(final String sessionId) {
		this.storage.remove(sessionId);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy