|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| UnlimitedCache.java | - | 100% | 100% | 100% |
|
||||||||||||||
| 1 | /* | |
| 2 | * Copyright (c) 2002-2006 by OpenSymphony | |
| 3 | * All rights reserved. | |
| 4 | */ | |
| 5 | package com.opensymphony.oscache.base.algorithm; | |
| 6 | ||
| 7 | import org.apache.commons.logging.Log; | |
| 8 | import org.apache.commons.logging.LogFactory; | |
| 9 | ||
| 10 | ||
| 11 | /** | |
| 12 | * A simple unlimited cache that has no upper bound to the number of | |
| 13 | * cache entries it can contain. | |
| 14 | * | |
| 15 | * @version $Revision: 427 $ | |
| 16 | * @author <a href="mailto:fbeauregard@pyxis-tech.com">Francois Beauregard</a> | |
| 17 | * @author <a href="mailto:abergevin@pyxis-tech.com">Alain Bergevin</a> | |
| 18 | */ | |
| 19 | public final class UnlimitedCache extends AbstractConcurrentReadCache { | |
| 20 | ||
| 21 | private static final long serialVersionUID = 7615611393249532285L; | |
| 22 | ||
| 23 | private final Log log = LogFactory.getLog(this.getClass()); | |
| 24 | ||
| 25 | /** | |
| 26 | * Creates an unlimited cache by calling the super class's constructor | |
| 27 | * with an <code>UNLIMITED</code> maximum number of entries. | |
| 28 | */ | |
| 29 | 157 | public UnlimitedCache() { |
| 30 | 157 | super(); |
| 31 | 157 | maxEntries = UNLIMITED; |
| 32 | } | |
| 33 | ||
| 34 | /** | |
| 35 | * Overrides the <code>setMaxEntries</code> with an empty implementation. | |
| 36 | * This property cannot be modified and is ignored for an | |
| 37 | * <code>UnlimitedCache</code>. | |
| 38 | */ | |
| 39 | 20 | public void setMaxEntries(int maxEntries) { |
| 40 | 20 | log.warn("Cache max entries can't be set in " + this.getClass().getName() + ", ignoring value " + maxEntries + "."); |
| 41 | } | |
| 42 | ||
| 43 | /** | |
| 44 | * Implements <code>itemRetrieved</code> with an empty implementation. | |
| 45 | * The unlimited cache doesn't care that an item was retrieved. | |
| 46 | */ | |
| 47 | 4499541 | protected void itemRetrieved(Object key) { |
| 48 | } | |
| 49 | ||
| 50 | /** | |
| 51 | * Implements <code>itemPut</code> with an empty implementation. | |
| 52 | * The unlimited cache doesn't care that an item was put in the cache. | |
| 53 | */ | |
| 54 | 412 | protected void itemPut(Object key) { |
| 55 | } | |
| 56 | ||
| 57 | /** | |
| 58 | * This method just returns <code>null</code> since items should | |
| 59 | * never end up being removed from an unlimited cache! | |
| 60 | */ | |
| 61 | 10 | protected Object removeItem() { |
| 62 | 10 | return null; |
| 63 | } | |
| 64 | ||
| 65 | /** | |
| 66 | * An empty implementation. The unlimited cache doesn't care that an | |
| 67 | * item was removed. | |
| 68 | */ | |
| 69 | 69 | protected void itemRemoved(Object key) { |
| 70 | } | |
| 71 | } |
|
||||||||||