Package com.killcoding.cache
Class CacheArray<T>
java.lang.Object
com.killcoding.cache.CacheArray<T>
- All Implemented Interfaces:
Serializable
This class use asynchronous caching to handle large result and large list.
Need class CacheArrayFilter to use.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static ExecutorServiceAll cache keys listprivate boolean'true' is completedprivate CacheArrayFilterprivate static booleanprotected Integerprotected Tprivate static Integerprotected Objectprotected Integerprivate static booleanprivate static Integer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd object to the cache listvoidAdd list to the cache listvoidfilter(CacheArrayFilter _filter) Need override the method to process logic handlestatic voidvoidget(int index) Get cache value by indexgetCacheKey(int index) Get cache key by indexGet all cache keysgetIndex()static IntegergetSize()static doublegetUsage()static Integerstatic voidinitPool(int poolSize) Check complete statusstatic Booleanstatic BooleanisStoped()remove(int index) Remove cache list index objectvoidRemove all cache listprivate static IntegersetUsingPoolSize(int value) intsize()Get all cache sizestatic voidstart()static voidstop()void
-
Field Details
-
MAX_POOL_SIZE
-
USING_POOL_SIZE
-
arrayPool
-
lastItem
-
stop
-
forceStop
-
filter
-
INDEX
-
SIZE
-
OBJECT
-
cacheKeys
All cache keys list -
completed
'true' is completed
-
-
Constructor Details
-
CacheArray
public CacheArray()New a CacheArray object
-
-
Method Details
-
initPool
-
filter
public CacheArrayFilter filter(long timer, Runnable executeRun, Runnable completedRun, Runnable terminatedRun) -
filter
Need override the method to process logic handle- Parameters:
filter- - CacheArrayFilter
-
getCacheKeys
Get all cache keys- Returns:
- List
-
size
Get all cache size -
add
Add object to the cache list- Returns:
- - return cacke key
-
addAll
Add list to the cache list- Parameters:
list- - It is object list value
-
remove
Remove cache list index object- Parameters:
index- - It is remove index cache- Returns:
- - return removed cache key name
-
removeAll
Remove all cache list -
get
Get cache value by index- Parameters:
index- - Cache index- Returns:
- - Cache value
-
getCacheKey
Get cache key by index- Parameters:
index- - Cache index- Returns:
- - Cache key
-
isCompleted
Check complete status- Returns:
- - 'true' is completed
-
isStoped
-
isForceStoped
-
stop
-
forceStop
-
start
-
terminate
-
forceTerminate
-
isTerminated
-
isForceTerminated
-
getIndex
-
getSize
-
getObject
-
setUsingPoolSize
-
getUsingPoolSize
-
getMaxPoolSize
-
getUsage
-