Menu

DiskCache_Implemented

silex6

Disk cache

This database software stack implements disk caching. This feature allows to manipulate huge files, minimize the number of time consuming I/O operation and remove the need to keep complete file into memory. The disk caching API provide paged access to a database file via the Cache and Page interfaces.

The disk cache package org.whitebear.cache is stable since 2021

Main interfaces

  • Cache - provide cached access to a pages file
  • Page - provide access to a file page. Current page size in 8kb
  • BufferReaderWriter - allow to read / write page content
  • WriteList - keep list of pages that need to be written back to the hard disk - actually to the operating system
  • LockList - allow to lock a set of pages in an single atomic operation

Current implementation

Current disk cache implementation use java.io.RandomAccessFile to access the database file. The disk cache uses java.nio.ByteBuffer to retain in-memory copies of disk content. All classes are thread-safe

CacheCleanupThread is a background thread responsible to remove unused pages from memory. It implements a 2nd chance algorithm

Memory mapping has not been implemented. Initial implementation led to many OutOfMemoryError. The implementation was then changed to use a HashMap to keep copies of the page into memory - into Java runtime's heap space

Copy-on-write and shadow copies feature is implemented by file container layer

See also

Disk cache specification


Related

Wiki: Disk_cache
Wiki: General_architecture

MongoDB Logo MongoDB