|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.nutiteq.cache.RmsCache
public class RmsCache
Caching inside record stores. Uses a collection of record stores (buckets) for caching. Record stores are created for every bucket and cache index.
Implemented with LRU (least recently used) strategy.
Values given in constructor are for maximum bucket size and number of
buckets. If phone limits are smaller, then this implementation adapts to
it.
For example cache with five buckets of size 64kB is created, but
phone has a max limit of three record stores for application with maximum
size of 30kB. Then we will have a cache with two buckets (one will be used
for index) with total size of 60kB.
Memory usage estimates
Cache holds a index of all files in memory and based on tile size and tile URL length it can differ significantly.
With OpenStreetMap tiles index size with 64kB bucket would be around 500-600 bytes. Bucket would contain 5-6 10kB images and for every image we would need to have in memory tile URL for cache key, bucket location and there is some object overhead.
With CloudMade tiles cache index size for 64kB bucket would be ~10kB. CloudMade images are a lot smaller (usually around 500B) and this also increases number of URLs needed for cache keys.
| Field Summary |
|---|
| Fields inherited from interface com.nutiteq.cache.Cache |
|---|
CACHE_LEVEL_MEMORY, CACHE_LEVEL_NONE, CACHE_LEVEL_PERSISTENT |
| Constructor Summary | |
|---|---|
RmsCache(java.lang.String cachePrefix,
int maxBucketSize,
int numberOfBuckets)
Creates a new record stores cache with given number of cache buckets. |
|
| Method Summary | |
|---|---|
void |
cache(java.lang.String cacheId,
byte[] data,
int cacheLevel)
Cache given data |
boolean |
contains(java.lang.String cacheKey)
Does this cache contain data for given cache key |
boolean |
contains(java.lang.String cacheKey,
int cacheLevel)
Does the specified cache level contain given cache key |
void |
deinitialize()
Clean up cache resources and, if needed, write cache definition/index somewhere. |
byte[] |
get(java.lang.String cacheId)
Get cached data. |
void |
initialize()
Initialize needed resources for cache. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RmsCache(java.lang.String cachePrefix,
int maxBucketSize,
int numberOfBuckets)
cachePrefix - prefix for cachemaxBucketSize - maximum bucket size in bytesnumberOfBuckets - number of buckets to be used| Method Detail |
|---|
public void initialize()
Cache
initialize in interface Cachepublic byte[] get(java.lang.String cacheId)
Cache
get in interface CachecacheId - key that was used for data caching
public void cache(java.lang.String cacheId,
byte[] data,
int cacheLevel)
Cache
cache in interface CachecacheId - key for the cached datadata - data to be cachedcacheLevel - at which level this data needs to be cached (memory, rms, etc).public void deinitialize()
Cache
deinitialize in interface Cachepublic boolean contains(java.lang.String cacheKey)
Cache
contains in interface CachecacheKey - cache key checked
public boolean contains(java.lang.String cacheKey,
int cacheLevel)
Cache
contains in interface CachecacheKey - cache key to be checkedcacheLevel - which cache levels to check
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||