KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jodd > cache > Cache


1 // Copyright (c) 2003-2007, Jodd Team (jodd.sf.net). All Rights Reserved.
2

3 package jodd.cache;
4
5 /**
6  * Cache interface.
7  */

8 public interface Cache {
9
10     /**
11      * Returns cache size or <code>0</code> if there is no size limit.
12      */

13     public int getCacheSize();
14
15     /**
16      * Returns default timeout or <code>0</code> if it is not set.
17      */

18     public long getCacheTimeout();
19
20     /**
21      * Adds an object to the cache with default timeout.
22      * @see Cache#put(Object, Object, long)
23      */

24     public void put(Object JavaDoc key, Object JavaDoc object);
25
26     /**
27      * Adds an object to the cache with specified timeout after which it becomes expired.
28      * If cache is full, prune is invoked to make room for new object.
29      */

30     public void put(Object JavaDoc key, Object JavaDoc object, long timeout);
31
32     /**
33      * Retrieves an object from the cache. Returns <code>null</code> if object
34      * is not longer in cache or if it is expired.
35      */

36     public Object JavaDoc get(Object JavaDoc key);
37
38     /**
39      * Prunes objects from cache and returns the number of removed objects.
40      * Which strategy is used depends on cache implementation.
41      */

42     public int prune();
43
44     /**
45      * Returns <code>true</code> if max cache capacity has been reached
46      * only if cache is size limited.
47      */

48     public boolean isFull();
49
50     /**
51      * Removes an object from the cache.
52      */

53     public void remove(Object JavaDoc key);
54
55     /**
56      * Clears current cache.
57      */

58     public void clear();
59
60     /**
61      * Returns current cache size.
62      */

63     public int size();
64 }
65
Popular Tags