Overview | Package | Class | Tree | Deprecated | Index | Help
| Protege 3.5 alpha
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.stanford.smi.protege.util.transaction.cache.impl
Class RepeatableReadCache<S,V,R>

    java.lang.Object
      edu.stanford.smi.protege.util.transaction.cache.impl.RepeatableReadCache<S,V,R>

All Implemented Interfaces:
  Cache<S,V,R>

    public class RepeatableReadCache<S,V,R>

extends Object
implements Cache<S,V,R>

Constructor Summary
`RepeatableReadCache(Cache<S,V,R> delegate)`

Method Summary
`void` | `abortCompleteCache()`
`void` | `beginTransaction(S session)` The session has entered a transaction.
`void` | `commitTransaction(S session)` A transaction is committed.
`void` | `finishCompleteCache()` The startCompleteCache and the finishCompleteCache are part of a protocol.
`void` | `flush()` Try to avoid this.
`int` | `getCacheId()` This method returns a unique id for each cache.
`int` | `getTransactionNesting(S session)` Returns the transaction nesting for a session.
`void` | `invalidate(S session)` This notifies the cache that this cache is now invalid either because the object that this cache represents is deleted or for any other reason.
`boolean` | `isCacheComplete()`
`boolean` | `isInvalid()` This indicates that the cache has entered the deleted state or is otherwise invalid.
`void` | `modifyCache(S session, V var)` This notifies the cache, that the caller has made a change to the value of the var.
`void` | `modifyCache(S session, V var, R value)` This notifies the cache that the caller has made a change to the value of var and that the caller knows the new value is value.
`CacheResult<R>` | `readCache(S session, V var)` If the variable var is cached then this returns the cached value.
`void` | `rollbackTransaction(S session)` A transaction is rolled back.
`void` | `startCompleteCache()` The startCompleteCache and the finishCompleteCache are part of a protocol.
`void` | `updateCache(S session, V var)` This call indicates that a read was scheduled but no useful value was retrieved.
`void` | `updateCache(S session, V var, R value)` The caller has received an update that the new value of var is value.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### RepeatableReadCache

    public RepeatableReadCache(Cache<S,V,R> delegate)

Method Detail

### readCache

    public CacheResult<R> readCache(S session,
                                    V var)

  Description copied from interface: `Cache`
  If the variable var is cached then this returns the cached value. It can be null in which case the isValid() method should be called to determine if this is just a missing cache element or actually the correct value. This call is required to never return null so that the code sequence

          CacheResult result = cache.readCache(session, var);
          if (result.isValid()) {
             return result.getValue();
          else {
             go to the source to  find the right value
          }

  works and is the recommended approach.

  Specified by:
    `readCache` in interface `Cache<S,V,R>`
    `var` - a variable
  Returns:
    the value in the cache for the variable var. Never returns null.

### updateCache

    public void updateCache(S session,
                            V var)

  Description copied from interface: `Cache`
  This call indicates that a read was scheduled but no useful value was retrieved. This can happen between a startCompleteCache and a finishCompleteCache. The process filling the cache is supposed to read all possible variables that might have a value. But the process either doesn't want to read the var (too expensive) or was not able to. This allows the cache to understand that it does not have a value at this var.

  Specified by:
    `updateCache` in interface `Cache<S,V,R>`
  Parameters:
    `session` - the session making the change

### updateCache

    public void updateCache(S session,
                            V var,
                            R value)

  Description copied from interface: `Cache`
  The caller has received an update that the new value of var is value. This as viewed as a value read. The session is important for two reasons. First, if the transaction isolation level is repeatable read, a session must not use the cache on the first read during a transaction even if the correct value is known. The underlying mechanism must be invoked so that it can record that a read has occurred. Second the session is important to determine if the value being read might be visible only in the single

  Specified by:
    `updateCache` in interface `Cache<S,V,R>`
  Parameters:
    `session` - the session making the change

### modifyCache

    public void modifyCache(S session,
                            V var)

  Description copied from interface: `Cache`
  This notifies the cache, that the caller has made a change to the value of the var. It is important that the caller always calls one of the modifyCache calls when making changes to cached values.

  Specified by:
    `modifyCache` in interface `Cache<S,V,R>`
  Parameters:
    `session` - the session making the change
    `var` - the variable being modified.

### modifyCache

    public void modifyCache(S session,
                            V var,
                            R value)

  Description copied from interface: `Cache`
  This notifies the cache that the caller has made a change to the value of var and that the caller knows the new value is value.

  Specified by:
    `modifyCache` in interface `Cache<S,V,R>`
  Parameters:
    `session` - the session making the change
    `var` - the variable being changed
    `value` - the new value for the variable

### invalidate

    public void invalidate(S session)

  Description copied from interface: `Cache`
  This notifies the cache that this cache is now invalid either because the object that this cache represents is deleted or for any other reason. If this change is outside a transaction or gets committed, the cache enters the invalid state. Once in the invalidated state all attempts to get a value return a value null value.

  Specified by:
    `invalidate` in interface `Cache<S,V,R>`

### isInvalid

    public boolean isInvalid()

  Description copied from interface: `Cache`
  This indicates that the cache has entered the deleted state or is otherwise invalid. A cache cannot recover from this state.

  Specified by:
    `isInvalid` in interface `Cache<S,V,R>`

### startCompleteCache

    public void startCompleteCache()

  Description copied from interface: `Cache`
  The startCompleteCache and the finishCompleteCache are part of a protocol. In the interval between the startCompleteCache and the finishCompleteCache, the values in the cache - with the exception of any entries that have been explicitly invalidated - are a complete list of all the real values.

  Specified by:
    `startCompleteCache` in interface `Cache<S,V,R>`

### finishCompleteCache

    public void finishCompleteCache()

  Description copied from interface: `Cache`
  The startCompleteCache and the finishCompleteCache are part of a protocol. In the interval between the startCompleteCache and the finishCompleteCache, the values in the cache - with the exception of any entries that have been explicitly invalidated - are a complete list of all the real values.

  Specified by:
    `finishCompleteCache` in interface `Cache<S,V,R>`

### abortCompleteCache

    public void abortCompleteCache()

  Specified by:
    `abortCompleteCache` in interface `Cache<S,V,R>`

### isCacheComplete

    public boolean isCacheComplete()

  Specified by:
    `isCacheComplete` in interface `Cache<S,V,R>`

### beginTransaction

    public void beginTransaction(S session)

  Description copied from interface: `Cache`
  The session has entered a transaction. Nesting is counted.

  Specified by:
    `beginTransaction` in interface `Cache<S,V,R>`

### commitTransaction

    public void commitTransaction(S session)

  Description copied from interface: `Cache`
  A transaction is committed.

  Specified by:
    `commitTransaction` in interface `Cache<S,V,R>`

### rollbackTransaction

    public void rollbackTransaction(S session)

  Description copied from interface: `Cache`
  A transaction is rolled back.

  Specified by:
    `rollbackTransaction` in interface `Cache<S,V,R>`

### getTransactionNesting

    public int getTransactionNesting(S session)

  Description copied from interface: `Cache`
  Returns the transaction nesting for a session. This is really just a convenience method for the implementation.

  Specified by:
    `getTransactionNesting` in interface `Cache<S,V,R>`

### flush

    public void flush()

  Description copied from interface: `Cache`
  Try to avoid this. If this is invoked and you are at READ_COMMITTED or above, the cache can repeatedly get flushed on commit and rollback transactions until everything is closed out.

  Specified by:
    `flush` in interface `Cache<S,V,R>`

### getCacheId

    public int getCacheId()

  Description copied from interface: `Cache`
  This method returns a unique id for each cache. This is to give the entire aspect stack of a cache to make logging and debugging easier

  Specified by:
    `getCacheId` in interface `Cache<S,V,R>`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Protege 3.5 alpha
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Submit a bug report or feature request
Protégé is a trademark of Stanford University.
Copyright (c) 1998-2012 Stanford University.