Package com.tagtraum.beatunes.library
Class PageCache<T>
- java.lang.Object
-
- com.tagtraum.beatunes.library.PageCache<T>
-
public class PageCache<T> extends Object
PageCache encapsulates and synchronizes all accesses to the cache.- Author:
- Hendrik Schreiber
-
-
Constructor Summary
Constructors Constructor Description PageCache(PageCacheDataSource<T> pageCacheDataSource)PageCache(PageCacheDataSource<T> pageCacheDataSource, int dataSourceCacheSize)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, long[] ids)Add entries to this cache.voidadd(long[] ids)Add entries to this cache.voidclear()Completely clears this cache.voidclearOrder()Clears just the order the cached items are in, but possibly still maintains copy of song objects.Tget(int index)This method might open and close its own session/transactions.List<T>getAll()HibernateUtilgetHibernateUtil()LonggetId(int index)intgetPageSize()intindexOf(long id)intindexOf(T object)booleanisAsyncLoading()booleanisUseDirectQuery()voidremove(int... indices)Remove the entries with the given indices from the cache.voidremoveFirstCached()voidremoveFromIndex(T persistentObject)static long[]removeIndices(long[] array, int... sortedIndicesToRemove)Remove indices from an array.voidreverseDirection()voidsetAsyncLoading(boolean asyncLoading)voidsetPageSize(int pageSize)voidsetUseDirectQuery(boolean useDirectQuery)voidupdate(T persistentObject)
-
-
-
Constructor Detail
-
PageCache
public PageCache(PageCacheDataSource<T> pageCacheDataSource)
-
PageCache
public PageCache(PageCacheDataSource<T> pageCacheDataSource, int dataSourceCacheSize)
-
-
Method Detail
-
getHibernateUtil
public HibernateUtil getHibernateUtil()
-
update
public void update(T persistentObject)
-
getId
public Long getId(int index)
-
get
public T get(int index)
This method might open and close its own session/transactions. It's therefore not recommended to call it from within your own transaction.- Parameters:
index- index- Returns:
- object
-
reverseDirection
public void reverseDirection()
-
clear
public void clear()
Completely clears this cache.
-
clearOrder
public void clearOrder()
Clears just the order the cached items are in, but possibly still maintains copy of song objects.- See Also:
clear()
-
indexOf
public int indexOf(T object)
-
indexOf
public int indexOf(long id)
-
removeFirstCached
public void removeFirstCached()
-
removeFromIndex
public void removeFromIndex(T persistentObject)
-
remove
public void remove(int... indices)
Remove the entries with the given indices from the cache.- Parameters:
indices- indices
-
add
public void add(long[] ids)
Add entries to this cache. Only makes sense, if the cache is in its natural order.- Parameters:
ids- ids to add at the end
-
add
public void add(int index, long[] ids)Add entries to this cache. Only makes sense, if the cache is in its natural order.- Parameters:
index- where to insert the idsids- ids to add at the end
-
removeIndices
public static long[] removeIndices(long[] array, int... sortedIndicesToRemove)Remove indices from an array. The indices have to be sorted ascendingly.- Parameters:
array- arraysortedIndicesToRemove- sorted indices (asc)- Returns:
- new array with the given indices removed
-
getPageSize
public int getPageSize()
-
setPageSize
public void setPageSize(int pageSize)
-
isUseDirectQuery
public boolean isUseDirectQuery()
-
setUseDirectQuery
public void setUseDirectQuery(boolean useDirectQuery)
-
isAsyncLoading
public boolean isAsyncLoading()
-
setAsyncLoading
public void setAsyncLoading(boolean asyncLoading)
-
-