org.eclipse.jgit.storage.dht.spi.cache
Class CacheDatabase

java.lang.Object
  extended by org.eclipse.jgit.storage.dht.spi.cache.CacheDatabase
All Implemented Interfaces:
Database

public class CacheDatabase
extends java.lang.Object
implements Database

Uses a cache for fast-lookups, but falls-back to another Database.

On a read miss, this database falls back to read another Database, and then puts the read value into the cache for later access.


Constructor Summary
CacheDatabase(Database database, java.util.concurrent.ExecutorService executor, CacheService client, CacheOptions options)
          Initialize a cache database.
 
Method Summary
 ChunkTable chunk()
           
 CacheService getClient()
           
 Database getDatabase()
           
 java.util.concurrent.ExecutorService getExecutorService()
           
 CacheOptions getOptions()
           
 CacheBuffer newWriteBuffer()
          Create a new WriteBuffer for the current thread.
 ObjectIndexTable objectIndex()
           
 RefTable ref()
           
 RepositoryTable repository()
           
 RepositoryIndexTable repositoryIndex()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheDatabase

public CacheDatabase(Database database,
                     java.util.concurrent.ExecutorService executor,
                     CacheService client,
                     CacheOptions options)
Initialize a cache database.

Parameters:
database - underlying storage database, used for read-misses and all writes.
executor - executor service to perform expensive cache updates in the background.
client - implementation of the cache service.
options - configuration of the cache.
Method Detail

getDatabase

public Database getDatabase()
Returns:
the underlying database the cache wraps.

getExecutorService

public java.util.concurrent.ExecutorService getExecutorService()
Returns:
executor pool for long operations.

getClient

public CacheService getClient()
Returns:
client connecting to the cache service.

getOptions

public CacheOptions getOptions()
Returns:
connection options for the cache service.

repositoryIndex

public RepositoryIndexTable repositoryIndex()
Specified by:
repositoryIndex in interface Database
Returns:
a handle to the table listing known repositories.

repository

public RepositoryTable repository()
Specified by:
repository in interface Database
Returns:
a handle to the table storing repository metadata.

ref

public RefTable ref()
Specified by:
ref in interface Database
Returns:
a handle to the table listing references in a repository.

objectIndex

public ObjectIndexTable objectIndex()
Specified by:
objectIndex in interface Database
Returns:
a handle to the table listing known objects.

chunk

public ChunkTable chunk()
Specified by:
chunk in interface Database
Returns:
a handle to the table listing pack data chunks.

newWriteBuffer

public CacheBuffer newWriteBuffer()
Description copied from interface: Database
Create a new WriteBuffer for the current thread.

Unlike other methods on this interface, the returned buffer must be a new object on every invocation. Buffers do not need to be thread-safe.

Specified by:
newWriteBuffer in interface Database
Returns:
a new buffer to handle pending writes.


Copyright © 2011. All Rights Reserved.