1 package org.eclipse.aether; 2 3 /* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 /** 23 * Caches auxiliary data used during repository access like already processed metadata. The data in the cache is meant 24 * for exclusive consumption by the repository system and is opaque to the cache implementation. <strong>Note:</strong> 25 * Actual cache implementations must be thread-safe. 26 * 27 * @see RepositorySystemSession#getCache() 28 */ 29 public interface RepositoryCache 30 { 31 32 /** 33 * Puts the specified data into the cache. It is entirely up to the cache implementation how long this data will be 34 * kept before being purged, i.e. callers must not make any assumptions about the lifetime of cached data. 35 * <p> 36 * <em>Warning:</em> The cache will directly save the provided reference. If the cached data is mutable, i.e. could 37 * be modified after being put into the cache, the caller is responsible for creating a copy of the original data 38 * and store the copy in the cache. 39 * 40 * @param session The repository session during which the cache is accessed, must not be {@code null}. 41 * @param key The key to use for lookup of the data, must not be {@code null}. 42 * @param data The data to store in the cache, may be {@code null}. 43 */ 44 void put( RepositorySystemSession session, Object key, Object data ); 45 46 /** 47 * Gets the specified data from the cache. 48 * <p> 49 * <em>Warning:</em> The cache will directly return the saved reference. If the cached data is to be modified after 50 * its retrieval, the caller is responsible to create a copy of the returned data and use this instead of the cache 51 * record. 52 * 53 * @param session The repository session during which the cache is accessed, must not be {@code null}. 54 * @param key The key to use for lookup of the data, must not be {@code null}. 55 * @return The requested data or {@code null} if none was present in the cache. 56 */ 57 Object get( RepositorySystemSession session, Object key ); 58 59 }