E - The type of object the cache stores. Typically, these are objects created from strings.public class ParsingCache<E> extends Object
Use case is when there is a need to repeatedly parse the same strings into objects, such as BigDecimal in the example test case, and would like to reuse the parsed object rather than creating a new one each time.
Example usage:
ParsingCache<BigDecimal> cache = new ParsingCache<>(128, BigDecimal::new);
BigDecimal value = cache.intern("123.456");
| Modifier and Type | Field and Description |
|---|---|
protected net.openhft.chronicle.core.pool.ParsingCache.ParsedData<E>[] |
interner |
protected int |
mask |
protected int |
shift |
protected boolean |
toggle |
| Constructor and Description |
|---|
ParsingCache(int capacity,
Function<String,E> eFunction)
Constructs a new ParsingCache with the specified capacity.
|
| Modifier and Type | Method and Description |
|---|---|
E |
intern(@Nullable CharSequence cs)
Retrieves the object associated with the given CharSequence from the cache.
|
protected boolean |
toggle() |
int |
valueCount()
Returns the number of values currently in the cache.
|
protected final net.openhft.chronicle.core.pool.ParsingCache.ParsedData<E>[] interner
protected final int mask
protected final int shift
protected boolean toggle
@Nullable public E intern(@Nullable @Nullable CharSequence cs)
cs - The CharSequence to be parsed.protected boolean toggle()
public int valueCount()
Copyright © 2024. All rights reserved.