| Class | Line # | Actions | |||||
|---|---|---|---|---|---|---|---|
| Cache | 33 | 0 | - | 0 | 0 |
| 1 | /* | |
| 2 | * See the NOTICE file distributed with this work for additional | |
| 3 | * information regarding copyright ownership. | |
| 4 | * | |
| 5 | * This is free software; you can redistribute it and/or modify it | |
| 6 | * under the terms of the GNU Lesser General Public License as | |
| 7 | * published by the Free Software Foundation; either version 2.1 of | |
| 8 | * the License, or (at your option) any later version. | |
| 9 | * | |
| 10 | * This software is distributed in the hope that it will be useful, | |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | * Lesser General Public License for more details. | |
| 14 | * | |
| 15 | * You should have received a copy of the GNU Lesser General Public | |
| 16 | * License along with this software; if not, write to the Free | |
| 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
| 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
| 19 | */ | |
| 20 | package org.xwiki.cache; | |
| 21 | ||
| 22 | import org.xwiki.cache.event.CacheEntryListener; | |
| 23 | ||
| 24 | /** | |
| 25 | * Cache interface. Used to add/get/remove value from cache which can be local or distributed, with a limited capacity | |
| 26 | * etc. depending of the implementation and configuration. | |
| 27 | * <p> | |
| 28 | * You can create a new cache using the {@link CacheFactory} component. | |
| 29 | * | |
| 30 | * @param <T> the class of the data stored in the cache. | |
| 31 | * @version $Id: a041726c64f3309a0b412366dbf0d8f94dbbf0ec $ | |
| 32 | */ | |
| 33 | public interface Cache<T> | |
| 34 | { | |
| 35 | /** | |
| 36 | * Add a new value or overwrite the existing one associated with the provided key. | |
| 37 | * <p> | |
| 38 | * You can catch this events using | |
| 39 | * {@link CacheEntryListener#cacheEntryAdded(org.xwiki.cache.event.CacheEntryEvent)} or | |
| 40 | * {@link CacheEntryListener#cacheEntryModified(org.xwiki.cache.event.CacheEntryEvent)} | |
| 41 | * </p> | |
| 42 | * | |
| 43 | * @param key the associated key used to access the value in the cache | |
| 44 | * @param value the value to store in the cache; if {@code null}, the cache entry is removed | |
| 45 | */ | |
| 46 | void set(String key, T value); | |
| 47 | ||
| 48 | /** | |
| 49 | * @param key the key used to access the value in the cache. | |
| 50 | * @return the value associated with the provided key, or {@code null} if there is no value. | |
| 51 | */ | |
| 52 | T get(String key); | |
| 53 | ||
| 54 | /** | |
| 55 | * Remove the entry associated with the provided key from the cache. | |
| 56 | * <p> | |
| 57 | * You can catch this events using | |
| 58 | * {@link CacheEntryListener#cacheEntryRemoved(org.xwiki.cache.event.CacheEntryEvent)} | |
| 59 | * </p> | |
| 60 | * | |
| 61 | * @param key the key used to access the value in the cache. | |
| 62 | */ | |
| 63 | void remove(String key); | |
| 64 | ||
| 65 | /** | |
| 66 | * Remove all the entries the cache contains. | |
| 67 | * | |
| 68 | * @see #remove(String) | |
| 69 | */ | |
| 70 | void removeAll(); | |
| 71 | ||
| 72 | /** | |
| 73 | * Add the provided listener to the cache to catch events on entries like add, remove etc. | |
| 74 | * | |
| 75 | * @param listener the implemented listener. | |
| 76 | */ | |
| 77 | void addCacheEntryListener(CacheEntryListener<T> listener); | |
| 78 | ||
| 79 | /** | |
| 80 | * Remove the provided listener from the list of listeners. | |
| 81 | * | |
| 82 | * @param listener the implemented listener. | |
| 83 | */ | |
| 84 | void removeCacheEntryListener(CacheEntryListener<T> listener); | |
| 85 | ||
| 86 | /** | |
| 87 | * Release all the resources this cache use. | |
| 88 | */ | |
| 89 | void dispose(); | |
| 90 | } |