SessionStore.java [src/csip] Revision: default  Date:
/*
 * $Id$
 *
 * This file is part of the Cloud Services Integration Platform (CSIP),
 * a Model-as-a-Service framework, API and application suite.
 *
 * 2012-2022, Olaf David and others, OMSLab, Colorado State University.
 *
 * OMSLab licenses this file to you under the MIT license.
 * See the LICENSE file in the project root for more information.
 */
package csip;

import java.util.Set;

/**
 * session store.
 */
interface SessionStore extends AutoCloseable {

  /**
   * Set a model session.
   *
   * @param suid
   * @param session
   * @throws Exception
   */
  void setSession(String suid, ModelSession session) throws Exception;


  /**
   * Get a model session
   * @param suid
   * @return the model session
   * @throws Exception
   */
  ModelSession getSession(String suid) throws Exception;


  boolean hasSession(String suid) throws Exception;


  /**
   * Remove a model session.
   *
   * @param suid
   */
  void removeSession(String suid);


  /**
   *
   * @param skip the number of keys to skip
   * @param limit the number of keys to return (0) means all
   * @param sortby the 'field' to sort by.
   * @param sortAscending true if sort is ascending, false otherwise.
   * @return the keys.
   */
  Set<String> keys(int skip, int limit, String sortby, boolean sortAscending);


  /**
   * Get the number of elements.
   * @return the number of elements.
   */
  long getCount();


  long countSessionsByState(String state);


  /**
   * Ping the store.
   *
   * @throws Exception if something is wrong.
   */
  void ping() throws Exception;


  void registerResources(boolean register);
}