Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.graph.connector.base.cache
Interface NodeCache<KeyType,NodeType extends Node>

Type Parameters:
  `KeyType` - the key for the cache entries, normally the natural unique identifier for the node
  `NodeType` - the node type that is being cached

All Known Subinterfaces:
  PathNodeCache<N>

All Known Implementing Classes:
  InMemoryNodeCache, InMemoryNodeCache.MapCache, InMemoryNodeCache.PathCache

    @ThreadSafe
    public interface NodeCache<KeyType,NodeType extends Node>

The basic contract for a workspace-level cache of paths to the nodes stored at that path.

Implementations must provide a no-argument constructor in order to be instantiated by `NodeCachePolicy`. After instantiation, the `assignPolicy(NodeCachePolicy)` method will be called to inject the cache policy into the implementation.

Implementations must be thread-safe.

Method Summary
`void` | `assignPolicy(NodeCachePolicy<KeyType,NodeType> policy)` Injects the cache policy into the cache
`void` | `clearStatistics()` Clears all statistics for this cache
`void` | `close()` Indicates that the cache is no longer in use and should relinquish any resources.
`NodeType` | `get(KeyType path)` Retrieves the cached node with the given path, it it exists and is valid
`CacheStatistics` | `getStatistics()`
`void` | `put(KeyType key, NodeType node)` Attempts to cache the given node.
`void` | `remove(KeyType key)` Removes the node with the given key from the cache, if it is in currently in the cache.
`void` | `removeAll()` Removes all nodes from the cache.

Method Detail

### assignPolicy

    void assignPolicy(NodeCachePolicy<KeyType,NodeType> policy)

  Injects the cache policy into the cache

  Parameters:
    `policy` - the active cache policy for the repository source with which this cache is associated
  Throws:
    `IllegalStateException` - if this method is called on a cache that has already been initialized.

### clearStatistics

    void clearStatistics()

  Clears all statistics for this cache

### getStatistics

    CacheStatistics getStatistics()

  Returns:
    the statistics since the most recent of the cache initialization or the last call to `clearStatistics()`; never null

### get

    NodeType get(KeyType path)

  Retrieves the cached node with the given path, it it exists and is valid

  Parameters:
    `path` - the path for the node to be retrieved
  Returns:
    the cached node with the given path; may be null if no node with that path is cached or a node with that path is cached but is deemed invalid for implementation-specific reasons

### put

    void put(KeyType key,
             NodeType node)

  Attempts to cache the given node. Implementations must call `NodeCachePolicy.shouldCache(Node)` on the the `assigned policy` to determine if the node should be cached.

  Parameters:
    `key` - the key for the node that is to be cached; may not be null
    `node` - the node that is to be cached; may not be null

### remove

    void remove(KeyType key)

  Removes the node with the given key from the cache, if it is in currently in the cache. If no node with the given key is currently in the cache, this method returns silently.

  Parameters:
    `key` - the key for the node that is to be removed; may not be null

### removeAll

    void removeAll()

  Removes all nodes from the cache.

### close

    void close()

  Indicates that the cache is no longer in use and should relinquish any resources.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.