public class StringEncoderCache extends AbstractStringCache
This class is thread safe. Thread safety is achieved by maintaining two data
structures. The first is a map of seen strings to the number of times the
string has been seen. The map is maintained by the base class:
AbstractStringCache. The second structure is a simple map of the
cached String to the encoded byte[]. The map has no locking
or synchronization since it is read-only after construction.
AbstractStringCache.ReverseIntegerComparatorDEFAULT_MAX_CACHE_ENTRIES, DEFAULT_MAX_CACHE_LENGTH, MAX_MULTIPLIER, myMaxCacheLength, myMaxCachEntries, myMaxCachEntriesMultiplier, mySeen, myUseCount| Constructor and Description |
|---|
StringEncoderCache()
Creates a new StringEncoder.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
clear()
Clears the cache.
|
byte[] |
find(String string)
Looks in the cache for encoded bytes for the specified string.
|
protected void |
rebuildCache()
Rebuilds the cache from the current collection of seen entries.
|
buildCacheGroups, getMaxCacheEntries, getMaxCacheLength, setMaxCacheEntries, setMaxCacheLength, usedpublic byte[] find(String string)
string - The string value to find the cached bytes for.null.protected void clear()
clear in class AbstractStringCacheprotected void rebuildCache()
rebuildCache in class AbstractStringCacheCopyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.