Package com.killcoding.cache
Class CacheArray
java.lang.Object
com.killcoding.cache.CacheArray
- 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 ExecutorServiceprotected final Listprotected IntegerAll cache keys listprivate boolean'true' is completedprivate CacheArrayFilterprivate static booleanprotected Integerprotected Objectprivate static Integerprivate booleanprotected Objectprotected Integerprivate static booleanprivate static Integer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd object to the cache listAdd object to the cache listvoidAdd list to the cache listfilter(long timer, long loopTimer, Runnable executeRun, Runnable executeBatchRun, Runnable completedRun, Runnable terminatedRun) voidfilter(CacheArrayFilter _filter) Need override the method to process logic handlestatic voidvoidget(int index) Get cache value by indexgetBatch()getCacheKey(int index) Get cache key by indexGet all cache keysgetIndex()static IntegergetSize()static doublegetUsage()static Integerstatic voidinitPool(int poolSize) Check complete statusstatic Booleanbooleanstatic BooleanisStoped()remove(int index) Remove cache list index objectvoidRemove all cache listvoidsetNulIsCompleted(boolean nullIsCompleted) private 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
-
nullIsCompleted
-
INDEX
-
SIZE
-
OBJECT
-
BATCH_INDEX
-
BATCH
-
cacheKeys
All cache keys list -
completed
'true' is completed
-
-
Constructor Details
-
CacheArray
public CacheArray()New a CacheArray object -
CacheArray
-
-
Method Details
-
initPool
-
filter
public CacheArrayFilter filter(long timer, Runnable executeRun, Runnable completedRun, Runnable terminatedRun) -
filter
-
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
-
add
Add object to the cache list- Returns:
- - return cacke key
- Throws:
InterruptedException
-
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
-
getBatch
-
getBatchIndex
-
setUsingPoolSize
-
getUsingPoolSize
-
getMaxPoolSize
-
getUsage
-
isNulIsCompleted
-
setNulIsCompleted
-