org.gnu.featherCache
Class Cache
- public class Cache
- implements java.util.Map, java.io.Serializable
- There is nothing much to explain about this class. It is simple, if you know that the java.util.Map is. The typical application uses caching in many independent places. Hence you must get a cache instance with the unique name by calling static method Cache.getCache("name"). Once you do this, use the returned Map as a java.util.Map. Please mind the following restrictions:
- The keys need not be strings, but must have a proper implemented toString() method.
- The values must be serializable.
- Several rarely needed methods are not implemented in the current version. If you need them, submit a RFE in SourceForge, https://sourceforge.net/projects/fca/.
The preferred way to use this module is to add it as a library. If you program has a GPL license, you can just incorporate it into your application in the source code level. @copyright: Copyright (c) 2004 Audrius Meskauskas, General Public License (GPL or LGPL)
- Version:
- 1.0
- Author:
- Audrius Meskauskas
cacheFolder
public static java.lang.String cacheFolder
- Specify the folder where all cache files will be stored (this is application specific). The default value will create the Cache subfolder is the current folder.
getCache
public static org.gnu.featherCache.Cache getCache(java.lang.String _header)
- Create or reuse the cache with the given header. For new caches, the two files with .content and .index extensions will be created in the specified cache folder. The index of all elements is resident. The elements are stored on the disk.
- See Also:
- clear()
containsKey
public boolean containsKey(java.lang.Object key)
- This Map method is implemented.
keySet
public java.util.Set keySet()
- This Map method is implemented.
put
private synchronized java.lang.Object put(java.lang.String key,
java.lang.Object v)
- This Map method is implemented.
get
private synchronized java.lang.Object get(java.lang.String key)
- This Map method is implemented.
size
public int size()
- This Map method is implemented.
isEmpty
public boolean isEmpty()
- This Map method is implemented.
remove
public java.lang.Object remove(java.lang.Object key)
- This Map method is implemented.
putAll
public void putAll(java.util.Map t)
- This Map method is implemented.
clear
public void clear()
- Clears the cache, also deleting the associated files.
equals
public boolean equals(java.lang.Object o)
- Returns true is the cache headers are equal.
hashCode
public int hashCode()
- Returns the cache header hash code.
get
public java.lang.Object get(java.lang.Object key)
- This Map method is implemented. To get a string value, key.toString() will be called.
setCacheExpirationTime
public void setCacheExpirationTime(int cacheExpirationTime)
- Set the expiration duration. The default value is 42 days.
- Parameters:
duration,
- in days, after that the cache item expires.
getCacheExpirationTime
public int getCacheExpirationTime()
- Get the time, in days, after that the cache item expires. The default value is 42 days.
containsValue
public boolean containsValue(java.lang.Object value)
- we have never needed this method, hence it is not implemented throwing UnuspportedOperationException. Values are not resident, so the implementation would be time expensive.
values
public java.util.Collection values()
- we have never needed this method, hence it is not implemented throwing UnuspportedOperationException. Values are not resident and usually these object are large and numerous. It may be not a good ide to load them all into memory. It is possible to write "virtual collection" that actually access the file, but we are not sure this is a best direction to extend the project.
entrySet
public java.util.Set entrySet()
- we have never needed this method, hence it is not implemented throwing UnuspportedOperationException.
isCacheEmptyNullIgnored
public boolean isCacheEmptyNullIgnored()
- If this property is set, zero-size arrays and collections are ignored in the cache.
setCacheEmptyNullIgnored
public void setCacheEmptyNullIgnored(boolean cacheEmptyNullIgnored)
- If this property is set, zero-size arrays and collections are ignored in the cache.
main
public static void main(java.lang.String[] args)
- Testing cache.
![](http://sourceforge.net/sflogo.php?group_id=124573&type=5)