# Housekeeping

{% hint style="warning" %}
**This is the manual for older MicroStream versions (Version < 5.0).**

**The new documentation (Version >= 5.0) is located at:**

[https://docs.microstream.one/](https://docs.microstream.one/manual)
{% endhint %}

## Intervall and Time Budget

[Housekeeping ](/data-store/housekeeping.md)interval and time budget is configured by setting up a `StorageHousekeepingController`.

Available properties are:

* [**House keeping interval**](/data-store/configuration/properties.md#housekeepinginterval)\
  interval the housekeeping is triggered in milliseconds, \
  default once per every second<br>
* [**House keeping budget**](/data-store/configuration/properties.md#housekeepingnanotimebudget)\
  time budget for housekeeping in nanoseconds,\
  default is 0.01 seconds

```java
EmbeddedStorageManager storage = EmbeddedStorage.Foundation(
	Storage.ConfigurationBuilder()
		.setHousekeepingController(Storage.HousekeepingController(1000, 10_000_000))
		.createConfiguration())
	.start();
```

## File Sizes and Payload

The desired file min and max sizes and payload ratio is configured by the `StorageDataFileEvaluator`:

available properties are:

* [**Data file minimum size**](/data-store/configuration/properties.md#datafileminimumsize)\
  Files smaller then minimum file size will be merged with other files if possible, default is 1 MB.<br>
* [**Data file maximum size**](/data-store/configuration/properties.md#datafilemaximumsize)\
  Files larger then maximum file size will be split in smaller ones, default is 8 MB.<br>
* [**Data file minimum use ratio**](/data-store/configuration/properties.md#datafileminimumuseratio)\
  Ratio of non-gap data contained in a storage file to prevent the file from being dissolved, default is 0.75 (75%).

```java
EmbeddedStorageManager storage = EmbeddedStorage.Foundation(
	Storage.ConfigurationBuilder()
		.setDataFileEvaluator(Storage.DataFileEvaluator(1024*1024, 1024*1024*8, 0.75))
		.createConfiguration())
	.start();
```

## Cache

The lifetime of objects in the internal entity cache can be configured by the `StorageEntityCacheEvaluator`:

Available properties are:

* **Entity cache threshold**

  Abstract threshold value, roughly comparable to size in bytes with a time component, at which a cache must be cleared of some entities. Default is `1000000000`.<br>
* **Entity cache timeout**\
  Time in milliseconds after that an entity is considered to be old if not read meanwhile. must be greater zero, default is `86400000ms` (1 day).

```java
EmbeddedStorageManager storage = EmbeddedStorage.Foundation(
	Storage.ConfigurationBuilder()
		.setEntityCacheEvaluator(Storage.EntityCacheEvaluator(
			86_400_000, 
			1_000_000_000))
		.createConfiguration())
	.start();
```

{% hint style="info" %}
For external configuration see: [Properties](/data-store/configuration/properties.md)
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://manual.docs.microstream.one/data-store/configuration/housekeeping.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
