com.sonyericsson.jenkins.plugins.bfa.graphs
Class GraphCache

java.lang.Object
  extended by com.sonyericsson.jenkins.plugins.bfa.graphs.GraphCache

public final class GraphCache
extends Object

A class for caching Graph-objects. Maps a string-key to each Graph-object.

Author:
Christoffer Lauri <christoffer.lauri@sonymobile.com>

Method Summary
 hudson.util.Graph get(String key, Callable<hudson.util.Graph> callable)
          Get the Graph corresponding to the specified key.
static int getExpirationTime()
          Gets the expiration time for cached objects.
static GraphCache getInstance()
          Get the singleton-instance.
 List<String> getMatchingCacheKeys(Pattern pattern)
          Gets all matching graph cache ids/keys.
 void invalidate(String key)
          Invalidate the object with the specified key.
 void invalidateMatching(Pattern pattern)
          Invalidates all graphs matching argument pattern.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static GraphCache getInstance()
Get the singleton-instance.

Returns:
GraphCache-instance

invalidate

public void invalidate(String key)
Invalidate the object with the specified key.

Parameters:
key - The key whose Graph to invalidate

invalidateMatching

public void invalidateMatching(Pattern pattern)
Invalidates all graphs matching argument pattern.

Parameters:
pattern - the pattern to match for graph ids

getMatchingCacheKeys

public List<String> getMatchingCacheKeys(Pattern pattern)
Gets all matching graph cache ids/keys.

Parameters:
pattern - the pattern to match for graph ids
Returns:
list of matching ids

getExpirationTime

public static int getExpirationTime()
Gets the expiration time for cached objects.

Returns:
expiration time in minutes

get

public hudson.util.Graph get(String key,
                             Callable<hudson.util.Graph> callable)
                      throws ExecutionException
Get the Graph corresponding to the specified key. If there is no cached graph for the specified key (or it has been invalidated) the specified Callable will be called.

Parameters:
key - The key for the graph
callable - A callback to construct the graph that wasn't cached
Returns:
A cached graph, or a new graph if there was no cached instance
Throws:
ExecutionException - If a graph e.g. cannot be generated


Copyright © 2004-2014. All Rights Reserved.