src/org/ohmage/cache/KeyValueCache.java
public String lookup(String key) throws CacheMissException {
		// If the lookup table is out-of-date, refresh it.
		if((getLastUpdateTimestamp() + getUpdateFrequency()) <= System
			.currentTimeMillis()) {
			refreshMap();
		}

		// If the key exists in the lookup table, return its value.
		if(keyValueMap.containsKey(key)) {
			return keyValueMap.get(key);
		}
		// Otherwise, throw an exception that it is an unknown state.
		else {
			throw new CacheMissException("Unknown key: " + key);
		}
	}
/**
	 * Compares the current timestamp with the last time we did an update plus
	 * the amount of time between updates. If our cache has become stale, we
	 * attempt to update it.
	 * 
	 * Then, we check to see if such a key exists in our cache. If not, we
	 * throw an exception because, if someone is querying for a key that
	 * doesn't exist, we need to bring it to their immediate attention rather
	 * than returning an "error" value. Otherwise, the corresponding integer
	 * value is returned.
	 * 
	 * It is recommended, but not required, to use the constants declared in
	 * the concrete cache class as the parameter.
	 * 
	 * The complexity is O(n) if a refresh is required; otherwise, the
	 * complexity of a Java Map object to lookup a key and return its value.
	 * 
	 * @param key
	 *        The key whose corresponding value is being requested.
	 * 
	 * @return The corresponding value.
	 * 
	 * @throws CacheMissException
	 *         Thrown if no such key exists.
	 */
Compares the current timestamp with the last time we did an update plus
the amount of time between updates. If our cache has become stale, we
attempt to update it.

Then, we check to see if such a key exists in our cache. If not, we
throw an exception because, if someone is querying for a key that
doesn't exist, we need to bring it to their immediate attention rather
than returning an "error" value. Otherwise, the corresponding integer
value is returned.

It is recommended, but not required, to use the constants declared in
the concrete cache class as the parameter.

The complexity is O(n) if a refresh is required; otherwise, the
complexity of a Java Map object to lookup a key and return its value.

@param key
The key whose corresponding value is being requested.

@return The corresponding value.

@throws CacheMissException
Thrown if no such key exists.
Compares the current timestamp with the last time we did an update plus the amount of time between updates . If our cache has become stale we attempt to update it . Then we check to see if such a key exists in our cache . If not we throw an exception because if someone is querying for a key that doesn ' t exist we need to bring it to their immediate attention rather than returning an " error " value . Otherwise the corresponding integer value is returned . It is recommended but not required to use the constants declared in the concrete cache class as the parameter . The complexity is O ( n ) if a refresh is required ; otherwise the complexity of a Java Map object to lookup a key and return its value . @param key The key whose corresponding value is being requested . @return The corresponding value . @throws CacheMissException Thrown if no such key exists .
public String lookup(String key) throws CacheMissException {
		if((getLastUpdateTimestamp() + getUpdateFrequency()) <= System
			.currentTimeMillis()) {
			refreshMap();
		}
		if(keyValueMap.containsKey(key)) {
			return keyValueMap.get(key);
		}
		else {
			throw new CacheMissException("Unknown key: " + key);
		}
	}
public String lookup ( String key ) throws CacheMissException { if ( ( getLastUpdateTimestamp ( ) + getUpdateFrequency ( ) ) <= System . currentTimeMillis ( ) ) { refreshMap ( ) ; } if ( keyValueMap . containsKey ( key ) ) { return keyValueMap . get ( key ) ; } else { throw new CacheMissException ( "Unknown key: " + key ) ; } }
Compares the current timestamp with the last time we did an update plus
 the amount of time between updates.
Compares the current timestamp with the last time we did an update plus the amount of time between updates .
// If the lookup table is out-of-date, refresh it. // If the key exists in the lookup table, return its value. // Otherwise, throw an exception that it is an unknown state.