com.j256.ormlite.dao
Interface ObjectCache

All Known Implementing Classes:
LruObjectCache, ReferenceObjectCache

public interface ObjectCache

Definition of an object cache that can be injected into the Dao with the Dao.setObjectCache(ObjectCache).

NOTE: Most of the below methods take a Class argument but your cache can be for a single cache. If this is the case then you should protect against storing different classes in the cache.

Author:
graywatson

Method Summary
<T> void
clear(Class<T> clazz)
          Remove all entries from the cache of a certain class.
 void clearAll()
          Remove all entries from the cache of all classes.
<T,ID> T
get(Class<T> clazz, ID id)
          Lookup in the cache for an object of a certain class that has a certain id.
<T,ID> void
put(Class<T> clazz, ID id, T data)
          Put an object in the cache that has a certain class and id.
<T,ID> void
remove(Class<T> clazz, ID id)
          Delete from the cache an object of a certain class that has a certain id.
<T> int
size(Class<T> clazz)
          Return the number of elements in the cache.
 int sizeAll()
          Return the number of elements in all of the caches.
<T,ID> T
updateId(Class<T> clazz, ID oldId, ID newId)
          Change the id in the cache for an object of a certain class from an old-id to a new-id.
 

Method Detail

get

<T,ID> T get(Class<T> clazz,
             ID id)
Lookup in the cache for an object of a certain class that has a certain id.

Returns:
The found object or null if none.

put

<T,ID> void put(Class<T> clazz,
                ID id,
                T data)
Put an object in the cache that has a certain class and id.


remove

<T,ID> void remove(Class<T> clazz,
                   ID id)
Delete from the cache an object of a certain class that has a certain id.


updateId

<T,ID> T updateId(Class<T> clazz,
                  ID oldId,
                  ID newId)
Change the id in the cache for an object of a certain class from an old-id to a new-id.


clear

<T> void clear(Class<T> clazz)
Remove all entries from the cache of a certain class.


clearAll

void clearAll()
Remove all entries from the cache of all classes.


size

<T> int size(Class<T> clazz)
Return the number of elements in the cache.


sizeAll

int sizeAll()
Return the number of elements in all of the caches.



This content is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.