| 1 | |
package org.webslinger.lang; |
| 2 | |
|
| 3 | |
public abstract class ConcurrentCache<K, V> extends AbstractConcurrentCache<K, V>{ |
| 4 | 1 | public static final ValueType HARD = ValueType.HARD; |
| 5 | 1 | public static final ValueType SOFT = ValueType.SOFT; |
| 6 | 1 | public static final ValueType WEAK = ValueType.WEAK; |
| 7 | |
|
| 8 | |
public ConcurrentCache(Class<?> owner, String field, String label) { |
| 9 | 0 | this(owner, field, label, null, false); |
| 10 | 0 | } |
| 11 | |
|
| 12 | |
public ConcurrentCache(Class<?> owner, String field, String label, boolean sorted) { |
| 13 | 0 | this(owner, field, label, null, sorted); |
| 14 | 0 | } |
| 15 | |
|
| 16 | |
public ConcurrentCache(Class<?> owner, String field, String label, AbstractConcurrentCache.ValueType valueType) { |
| 17 | 1973 | this(owner, field, label, valueType, false); |
| 18 | 1973 | } |
| 19 | |
|
| 20 | |
public ConcurrentCache(Class<?> owner, String field, String label, AbstractConcurrentCache.ValueType valueType, boolean sorted) { |
| 21 | 1973 | super(owner, field, label, valueType, sorted); |
| 22 | 1973 | } |
| 23 | |
|
| 24 | |
public V get(K key) throws Exception { |
| 25 | 7285 | return get(null, key); |
| 26 | |
} |
| 27 | |
|
| 28 | |
public V get(K key, boolean create) throws Exception { |
| 29 | 118568 | return get(null, key, create); |
| 30 | |
} |
| 31 | |
|
| 32 | |
protected V createValue(Object id, K key) throws Exception { |
| 33 | 1658 | return createValue(key); |
| 34 | |
} |
| 35 | |
|
| 36 | |
protected abstract V createValue(K key) throws Exception; |
| 37 | |
|
| 38 | |
protected V findIfExists(Object id, K key) throws Exception { |
| 39 | 104912 | return findIfExists(key); |
| 40 | |
} |
| 41 | |
|
| 42 | |
protected V findIfExists(K key) throws Exception { |
| 43 | 0 | return null; |
| 44 | |
} |
| 45 | |
} |