Class InMemoryRepository

All Implemented Interfaces:
AutoCloseable

public class InMemoryRepository extends DfsRepository
Git repository stored entirely in the local process memory.

This implementation builds on the DFS repository by storing all reference and object data in the local process. It is not very efficient and exists only for unit testing and small experiments.

The repository is thread-safe. Memory used is released only when this object is garbage collected. Closing the repository has no impact on its memory.

  • Constructor Details

    • InMemoryRepository

      public InMemoryRepository(DfsRepositoryDescription repoDesc)
      Initialize a new in-memory repository.
      Parameters:
      repoDesc - description of the repository.
  • Method Details

    • createRefDatabase

      protected InMemoryRepository.MemRefDatabase createRefDatabase()
      Creates a new in-memory ref database.
      Returns:
      a new in-memory reference database.
    • getObjectDatabase

      public InMemoryRepository.MemObjDatabase getObjectDatabase()
      Description copied from class: Repository
      Get the object database which stores this repository's data.
      Specified by:
      getObjectDatabase in class DfsRepository
      Returns:
      the object database which stores this repository's data.
    • getRefDatabase

      public RefDatabase getRefDatabase()
      Description copied from class: Repository
      Get the reference database which stores the reference namespace.
      Specified by:
      getRefDatabase in class Repository
      Returns:
      the reference database which stores the reference namespace.
    • setPerformsAtomicTransactions

      public void setPerformsAtomicTransactions(boolean atomic)
      Enable (or disable) the atomic reference transaction support.

      Useful for testing atomic support enabled or disabled.

      Parameters:
      atomic - whether to use atomic reference transaction support
    • getGitwebDescription

      @Nullable public String getGitwebDescription()
      Description copied from class: Repository
      Read the GIT_DIR/description file for gitweb.
      Overrides:
      getGitwebDescription in class Repository
      Returns:
      description text; null if no description has been configured.
    • setGitwebDescription

      public void setGitwebDescription(@Nullable String d)
      Description copied from class: Repository
      Set the GIT_DIR/description file for gitweb.
      Overrides:
      setGitwebDescription in class Repository
      Parameters:
      d - new description; null to clear the description.