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

com.aerospike.session.SessionStore Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) 2008-2015 Aerospike, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.aerospike.session;

import java.util.Map;

/**
 * A store for session data. A session is identified by a string session id
 * generated by a {@link SessionIDProvider}. The session store allows one to
 * store arbitrary key value pairs for a session.
 *
 * 

* This session store is meant to used on each node to serve a cluster of * web-applications *

* *

*

Expiry

* The store can be configured with a session timeout at startup. A session * expires if there has been no get / put / touch operation for that session id * for a session timeout interval. *

* * * @author ashish * */ public interface SessionStore { /** * Add a key value pair associated with the current session. If a key value * pair with the key already exists, the value will be overwritten. As a * side effect marks this session as in use and reset the ttl to the session * store expiry if set. * * @param key * the key * @param value * the value */ void put(final String key, final Object value) throws SessionStoreException; /** * Add batch of key value pairs associated with the current session. If a * key value pair with a key already exists, the value will be overwritten. * As a side effect marks this session as in use and reset the ttl to the * session store expiry if set. * * * @param map * the key value pairs to write to the session store. * @throws SessionStoreException * if session storage failed to read. */ void putAll(final Map map) throws SessionStoreException; /** * Read the value for a key associated with current session. * * @param key * the key. * * @throws SessionNotFound * if the session has expired or does not exist. * @throws SessionStoreException * if session storage failed to read. */ Object get(final String key) throws SessionNotFound, SessionStoreException; /** * Read all key value pairs associated with current session. * * @throws SessionNotFound * if the session has expired or does not exist. * @throws SessionStoreException * if session storage failed to read. */ Map getAll() throws SessionNotFound, SessionStoreException; /** * Touch current session so that its expiry is advanced. * * @throws SessionStoreException * if session storage failed to update the session expiry. */ void touch() throws SessionNotFound, SessionStoreException; /** * Destroy a current session. * * @throws SessionStoreException * if session storage failed to destroy the session.. */ void destroy() throws SessionStoreException; /** * Read all key value pairs associated with current session , and invoke * checkAndSetOperation atomically. * * @param operation * check and set operation */ void checkAndSet(final CheckAndSetOperation operation) throws SessionStoreException, SessionNotFound; /** * Indicates if there is an active session. * * @throws SessionStoreException * if session storage failed to read. */ boolean exists() throws SessionStoreException; /** * Create a session if it does not exist. * * @throws SessionStoreException */ void create() throws SessionStoreException; }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy