楼上的大哥:
你的代码还没来得及研究,我只是在JB中新建一个项目,然后新建class,copy了你的代码,
然后把首行package修改成我自己的package,但是程序throws CacheException的地方都标记为红色错误标记,怎么回事?错误信息:"Cache.java": cannot resolve symbol: class CacheException in interface smscache.Cache at line 16, column 38 还有,CachedItem.java中,freshTimestamp = Timestamper.next();和unlockTimestamp = Timestamper.next();这两行都有红色错误标记,错误信息是:"CachedItem.java": cannot resolve symbol: variable Timestamper in class smscache.CachedItem at line 22, column 18
/**
* Implementors manage transactional access to cached data. Transactions
* pass in a timestamp indicating transaction start time.
*/
public interface CacheConcurrencyStrategy {
/**
* Attempt to retrieve an object from the cache
* @param key
* @param txTimestamp a timestamp prior to the transaction start time
* @return the cached object or <tt>null</tt>
* @throws CacheException
*/
public Object get(Object key, long txTimestamp) throws CacheException;
/**
* Attempt to cache an object
* @param key
* @param value
* @param txTimestamp a timestamp prior to the transaction start time
* @return <tt>true</tt> if the object was successfully cached
* @throws CacheException
*/
public boolean put(Object key, Object value, long txTimestamp) throws CacheException;
/**
* We are going to attempt to update/delete the keyed object
* @param key
* @throws CacheException
*/
public void lock(Object key) throws CacheException;
/**
* We have finished the attempted update/delete (which may or may
* not have been successful).
* @param key
* @throws CacheException
*/
public void release(Object key) throws CacheException;
public void remove(Object key) throws CacheException;
public void clear() throws CacheException;
public void destroy();
}
/**
* An item of cached data, timestamped with the time it was cached,
* when it was locked, when it was unlocked.
* @see ReadWriteCache
*/
public final class CachedItem implements Serializable {
private long freshTimestamp;
private boolean fresh;
private long unlockTimestamp;
private int lock;
private Object value;
/**
* Implementors define a caching algorithm. All implementors
* <b>must</b> be threadsafe.
*/
public interface Cache {
/**
* Get an item from the cache
* @param key
* @return the cached object or <tt>null</tt>
* @throws CacheException
*/
public Object get(Object key) throws CacheException;
/**
* Add an item to the cache
* @param key
* @param value
* @throws CacheException
*/
public void put(Object key, Object value) throws CacheException;
/**
* Remove an item from the cache
*/
public void remove(Object key) throws CacheException;
/**
* Clear the cache
*/
public void clear() throws CacheException;
/**
* Clean up
*/
public void destroy() throws CacheException;
/**
* Set the cache region name
* @param regionName
* @throws CacheException
*/
public void setRegion(String regionName) throws CacheException;
}