01: package org.hibernate.cache;
02:
03: /**
04: * A contract for transactional cache implementations which support
05: * optimistic locking of items within the cache.
06: * <p/>
07: * The optimisitic locking capabilities are only utilized for
08: * the entity cache regions.
09: * <p/>
10: * Unlike the methods on the {@link Cache} interface, all the methods
11: * here will only ever be called from access scenarios where versioned
12: * data is actually a possiblity (i.e., entity data). Be sure to consult
13: * with {@link OptimisticCacheSource#isVersioned()} to determine whether
14: * versioning is actually in effect.
15: *
16: * @author Steve Ebersole
17: */
18: public interface OptimisticCache extends Cache {
19: /**
20: * Indicates the "source" of the cached data. Currently this will
21: * only ever represent an {@link org.hibernate.persister.entity.EntityPersister}.
22: * <p/>
23: * Made available to the cache so that it can access certain information
24: * about versioning strategy.
25: *
26: * @param source The source.
27: */
28: public void setSource(OptimisticCacheSource source);
29:
30: /**
31: * Called during {@link CacheConcurrencyStrategy#insert} processing for
32: * transactional strategies. Indicates we have just performed an insert
33: * into the DB and now need to cache that entity's data.
34: *
35: * @param key The cache key.
36: * @param value The data to be cached.
37: * @param currentVersion The entity's version; or null if not versioned.
38: */
39: public void writeInsert(Object key, Object value,
40: Object currentVersion);
41:
42: /**
43: * Called during {@link CacheConcurrencyStrategy#update} processing for
44: * transactional strategies. Indicates we have just performed an update
45: * against the DB and now need to cache the updated state.
46: *
47: * @param key The cache key.
48: * @param value The data to be cached.
49: * @param currentVersion The entity's current version
50: * @param previousVersion The entity's previous version (before the update);
51: * or null if not versioned.
52: */
53: public void writeUpdate(Object key, Object value,
54: Object currentVersion, Object previousVersion);
55:
56: /**
57: * Called during {@link CacheConcurrencyStrategy#put} processing for
58: * transactional strategies. Indicates we have just loaded an entity's
59: * state from the database and need it cached.
60: *
61: * @param key The cache key.
62: * @param value The data to be cached.
63: * @param currentVersion The entity's version; or null if not versioned.
64: */
65: public void writeLoad(Object key, Object value,
66: Object currentVersion);
67: }
|