|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectvelosurf.cache.Cache
public class Cache
Cache that keeps fetched instances in memory.
Three modes :
Warning: Velosurf will invalidate entries on update requests, but global updates are not taken into account.
This caching mechanism is meant for straightforward optimizations in simple situations, for instance to avoid re-fetching the loggued user at each request.
| Nested Class Summary | |
|---|---|
static class |
Cache.ArrayKey
|
| Field Summary | |
|---|---|
protected int |
cachingMethod
The caching method this cache uses |
static int |
FULL_CACHE
constant used to specify the "full cache" mode |
protected java.util.Map |
innerCache
the inner map that stores associations |
static int |
NO_CACHE
constant used to specify the "no cache" mode |
static int |
SOFT_CACHE
constant used to specify the "soft cache" mode |
| Constructor Summary | |
|---|---|
Cache(int cachingMethod)
Cache constructor |
|
| Method Summary | |
|---|---|
void |
clear()
Clear the cache |
java.lang.Object |
get(java.lang.Object key)
Try to get an instance from the cache |
void |
invalidate(java.lang.Object key)
invalidates an entry (used after an insert or an update) |
void |
put(java.lang.Object key,
java.lang.Object value)
Put an instance in the cache |
int |
size()
Getter for the size of the cache |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int NO_CACHE
public static final int SOFT_CACHE
public static final int FULL_CACHE
protected int cachingMethod
protected java.util.Map innerCache
| Constructor Detail |
|---|
public Cache(int cachingMethod)
cachingMethod - required caching mode| Method Detail |
|---|
public void put(java.lang.Object key,
java.lang.Object value)
key - key field(s) of this instancevalue - instancepublic int size()
public java.lang.Object get(java.lang.Object key)
key - key field(s) of the asked instance
public void clear()
public void invalidate(java.lang.Object key)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||