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

com.cinchapi.impromptu.server.api.store.Cache Maven / Gradle / Ivy

/*
 * Copyright (c) 2013-2017 Cinchapi 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.cinchapi.impromptu.server.api.store;

/**
 * A persistent key/value cache that can be used to make recipe derivations more
 * performance by saving permanent or semi-permanent data for future executions.
 * 
 * @author Jeff Nelson
 */
public interface Cache {

    /**
     * Delete the {@code key} from the cache
     * 
     * @param key the key name
     */
    public void delete(String key);

    /**
     * Retrieve the latest value for a {@code key} from the cache.
     * 
     * @param key the lookup key
     * @return the latest value for the {@code key} or {@code null} if no value
     *         is currently stored for the key
     */
    public  T get(String key);

    /**
     * Retrieve the value that was cached for {@code key} at {@code timestamp}.
     * 
     * @param key the lookup key
     * @param timestamp the lookup timestamp, in microseconds
     * @return the value for the {@code key} at {@code timestamp} or
     *         {@code null} if no value was stored for the key at the time
     */
    public  T get(String key, long timestamp);

    /**
     * Retrieve the latest value for {@code key} from the cache if it was stored
     * after {@code timestamp}; otherwise return {@code null}.
     * 
     * @param key the lookup key
     * @param timestamp the lookup timestamp, in microseconds
     * @return the latest value for the {@code key} or {@code null} if no value
     *         is currently stored for the key or the current value was stored
     *         before {@code timestamp}
     */
    public  T getIfAfter(String key, long timestamp);

    /**
     * Place a mapping from {@code key} to {@code value} in the cache.
     * 
     * @param key the key name
     * @param value the value to associate with the {@code key} in the cache
     */
    public  void put(String key, T value);

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy