Class InMemoryRepository

All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
RefsUnreadableInMemoryRepository

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.

  • Field Details

  • Constructor Details

    • InMemoryRepository

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

      InMemoryRepository(InMemoryRepository.Builder builder)
  • Method Details

    • getObjectDatabase

      public InMemoryRepository.MemObjDatabase getObjectDatabase()
      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()
      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()
      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)
      Set the GIT_DIR/description file for gitweb.
      Overrides:
      setGitwebDescription in class Repository
      Parameters:
      d - new description; null to clear the description.