001/*
002 * (C) Copyright 2015 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 * Nuxeo - initial API and implementation
016 */
017
018package org.nuxeo.ecm.core.transientstore.api;
019
020import org.nuxeo.common.annotation.Experimental;
021
022/**
023 * Service Interface for managing a transient store.
024 *
025 * @author <a href="mailto:tdelprat@nuxeo.com">Tiry</a>
026 * @since 7.2
027 */
028@Experimental(comment = "https://jira.nuxeo.com/browse/NXP-16577")
029public interface TransientStore {
030
031    /**
032     * Adds a new {@link StorageEntry}.
033     */
034    void put(StorageEntry entry);
035
036    /**
037     * Returns a {@link StorageEntry} given its {@code key}, or null if not found.
038     */
039    StorageEntry get(String key);
040
041    /**
042     * Removes a {@link StorageEntry} given its {@code key}.
043     */
044    void remove(String key);
045
046    /**
047     * Informs the Store that the entry can be released if TTL or GC parameters requires to do some cleanup.
048     */
049    void release(String key);
050
051    /**
052     * Runs the Garbage Collecting to delete the Filesystem resources that may correspond to cache entries that were
053     * removed
054     */
055    void doGC();
056
057    /**
058     * Returns the size of the disk storage used in MB
059     */
060    int getStorageSizeMB();
061
062    /**
063     * Shutdown the store.
064     */
065    void shutdown();
066
067    /**
068     * Initialize the store from the configuration
069     */
070    void init(TransientStoreConfig config);
071
072}