1 package org.sonatype.aether; 2 3 /******************************************************************************* 4 * Copyright (c) 2010-2011 Sonatype, Inc. 5 * All rights reserved. This program and the accompanying materials 6 * are made available under the terms of the Eclipse Public License v1.0 7 * which accompanies this distribution, and is available at 8 * http://www.eclipse.org/legal/epl-v10.html 9 *******************************************************************************/ 10 11 /** 12 * Caches auxiliary data used during repository access like already processed metadata. The data in the cache is meant 13 * for exclusive consumption by the repository system and is opaque to the cache implementation. <strong>Note:</strong> 14 * Actual cache implementations must be thread-safe. 15 * 16 * @author Benjamin Bentmann 17 */ 18 public interface RepositoryCache 19 { 20 21 /** 22 * Puts the specified data into the cache. It is entirely up to the cache implementation how long this data will be 23 * kept before being purged, i.e. callers must not make any assumptions about the lifetime of cached data. 24 * <strong>Warning:</strong> The cache will directly save the provided reference. If the cached data is mutable, 25 * i.e. could be modified after being put into the cache, the caller is responsible for creating a copy of the 26 * original data and store the copy in the cache. 27 * 28 * @param session The repository session during which the cache is accessed, must not be {@code null}. 29 * @param key The key to use for lookup the data with, must not be {@code null}. 30 * @param data The data to store in the cache, may be {@code null}. 31 */ 32 void put( RepositorySystemSession session, Object key, Object data ); 33 34 /** 35 * Gets the specified data from the cache. <strong>Warning:</strong> The cache will directly return the saved 36 * reference. If the cached data is to be modified after its retrieval, the caller is responsible to create a copy 37 * of the returned data and use this instead of the cache record. 38 * 39 * @param session The repository session during which the cache is accessed, must not be {@code null}. 40 * @param key The key to use for lookup of the data, must not be {@code null}. 41 * @return The requested data or {@code null} if none was present in the cache. 42 */ 43 Object get( RepositorySystemSession session, Object key ); 44 45 }