org.apache.blur
Class CachedMap

java.lang.Object
  extended by org.apache.blur.CachedMap
Direct Known Subclasses:
ZkCachedMap

public abstract class CachedMap
extends Object


Constructor Summary
CachedMap()
           
 
Method Summary
abstract  void clearCache()
          Clears the in memory cache of the map, this forces a re-read from the source.
abstract  Map<String,String> fetchAllFromSource()
          Fetches all the keys and values for the map from the source.
abstract  String get(String key)
          Fetches the value by key, if the in memory cache is missing the value then re-read from source if missing from source return null.
abstract  boolean putIfMissing(String key, String value)
          Puts the value with the given key into the map if the key was missing.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachedMap

public CachedMap()
Method Detail

clearCache

public abstract void clearCache()
                         throws IOException
Clears the in memory cache of the map, this forces a re-read from the source.

Throws:
IOException

get

public abstract String get(String key)
                    throws IOException
Fetches the value by key, if the in memory cache is missing the value then re-read from source if missing from source return null.

Parameters:
key - the key.
Returns:
the value.
Throws:
IOException

putIfMissing

public abstract boolean putIfMissing(String key,
                                     String value)
                              throws IOException
Puts the value with the given key into the map if the key was missing. Returns true if the key with the given value was set otherwise false if a key already existed.

Parameters:
key - the key.
value - the value.
Returns:
boolean true is successful, false if not.
Throws:
IOException

fetchAllFromSource

public abstract Map<String,String> fetchAllFromSource()
                                               throws IOException
Fetches all the keys and values for the map from the source. That means this an expensive operation and should be used sparingly.

Returns:
the map of all keys to values.
Throws:
IOException


Copyright © 2012-2014 The Apache Software Foundation. All Rights Reserved.