org.infinispan.container
Interface DataContainer

All Superinterfaces:
Iterable<InternalCacheEntry>
All Known Implementing Classes:
FIFODataContainer, FIFOSimpleDataContainer, LRUDataContainer, LRUSimpleDataContainer, SimpleDataContainer

public interface DataContainer
extends Iterable<InternalCacheEntry>

The main internal data structure which stores entries

Since:
4.0
Author:
Manik Surtani (manik@jboss.org), Galder ZamarreƱo

Method Summary
 void clear()
          Removes all entries in the container
 boolean containsKey(Object k)
          Tests whether an entry exists in the container
 Set<InternalCacheEntry> entrySet()
          Returns a mutable set of immutable cache entries exposed as immutable Map.Entry instances.
 InternalCacheEntry get(Object k)
          Retrieves a cached entry
 Set<Object> keySet()
          Returns a set of keys in the container.
 InternalCacheEntry peek(Object k)
          Retrieves a cache entry in the same way as get(Object)} except that it does not update or reorder any of the internal constructs.
 void purgeExpired()
          Purges entries that have passed their expiry time
 void put(Object k, Object v, long lifespan, long maxIdle)
          Puts an entry in the cache along with a lifespan and a maxIdle time
 InternalCacheEntry remove(Object k)
          Removes an entry from the cache
 int size()
           
 Collection<Object> values()
           
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

get

InternalCacheEntry get(Object k)
Retrieves a cached entry

Parameters:
k - key under which entry is stored
Returns:
entry, if it exists and has not expired, or null if not

peek

InternalCacheEntry peek(Object k)
Retrieves a cache entry in the same way as get(Object)} except that it does not update or reorder any of the internal constructs. I.e., expiration does not happen, and in the case of the LRU container, the entry is not moved to the end of the chain. This method should be used instead of get(Object)} when called while iterating through the data container using methods like keySet() to avoid changing the underlying collection's order.

Parameters:
k - key under which entry is stored
Returns:
entry, if it exists, or null if not

put

void put(Object k,
         Object v,
         long lifespan,
         long maxIdle)
Puts an entry in the cache along with a lifespan and a maxIdle time

Parameters:
k - key under which to store entry
v - value to store
lifespan - lifespan in milliseconds. -1 means immortal.
maxIdle - max idle time for which to store entry. -1 means forever.

containsKey

boolean containsKey(Object k)
Tests whether an entry exists in the container

Parameters:
k - key to test
Returns:
true if entry exists and has not expired; false otherwise

remove

InternalCacheEntry remove(Object k)
Removes an entry from the cache

Parameters:
k - key to remove
Returns:
entry removed, or null if it didn't exist or had expired

size

int size()
Returns:
count of the number of entries in the container

clear

void clear()
Removes all entries in the container


keySet

Set<Object> keySet()
Returns a set of keys in the container. When iterating through the container using this method, clients should never call #get() method but instead #peek(), in order to avoid changing the order of the underlying collection as a side of effect of iterating through it.

Returns:
a set of keys

values

Collection<Object> values()
Returns:
a set of values contained in the container

entrySet

Set<InternalCacheEntry> entrySet()
Returns a mutable set of immutable cache entries exposed as immutable Map.Entry instances. Clients of this method such as Cache.entrySet() operation implementors are free to convert the set into an immutable set if needed, which is the most common use case. If a client needs to iterate through a mutable set of mutable cache entries, it should iterate the container itself rather than iterating through the return of entrySet().

Returns:
a set of immutable cache entries

purgeExpired

void purgeExpired()
Purges entries that have passed their expiry time


Google Analytics

Copyright © 2010 JBoss, a division of Red Hat. All Rights Reserved.