Overview | Package | Class | Tree | Deprecated | Index | Help
| Protege 3.4 rc2
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 BasicCache<S,V,R>

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

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

    public class BasicCache<S,V,R>

extends Object
implements Cache<S,V,R>

This is a basic cache that - ignores the impact of transactions on the cache. - ignores deletion functionality - ignore the cache completion mechanism (at least this one is correct...) It will only return valid results in the case that the transaction isolation level is NONE or where the caller covers the in transaction case.

Author:
  tredmond

Constructor Summary
`BasicCache()`

Method Summary
`void` | `abortCompleteCache()`
`void` | `beginTransaction(S session)` The session has entered a transaction.
`void` | `commitTransaction(S session)` A transaction is committed.
`void` | `delete(S session)` This notifies the cache that the caller has made deleted the object that this cache represents.
`void` | `finishCompleteCache()` The startCompleteCache and the finishCompleteCache are part of a protocol.
`void` | `flush()` Try to avoid this.
`int` | `getTransactionNesting(S session)` Returns the transaction nesting for a session.
`boolean` | `isCacheComplete()`
`boolean` | `isDeleted()` This indicates that the cache has entered the deleted state.
`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

### BasicCache

    public BasicCache()

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

### delete

    public void delete(S session)

  Description copied from interface: `Cache`
  This notifies the cache that the caller has made deleted the object that this cache represents. If this change is outside a transaction or gets committed, the cache enters the deleted state. Once in the deleted state all attempts to get a value return a value null value. Attempts to modify the cache after it has entered the deleted state will bring the cache back.

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

### isDeleted

    public boolean isDeleted()

  Description copied from interface: `Cache`
  This indicates that the cache has entered the deleted state. Once in this state the cache cannot recover.

  Specified by:
    `isDeleted` 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>`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Protege 3.4 rc2
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-2009 Stanford University.