> For the complete documentation index, see [llms.txt](https://manual.docs.microstream.one/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://manual.docs.microstream.one/4.0/cache/configuration/storage.md).

# Storage

{% 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 %}

MicroStream's storage can be used as a backing store for the cache. It functions as a CacheWriter as well as a CacheReader, depending on the writeThrough and readThrough configuration. Per default it is used for both.

```java
EmbeddedStorageManager storageManager = EmbeddedStorage.start();
CachingProvider        provider       = Caching.getCachingProvider();  
CacheManager           cacheManager   = provider.getCacheManager();   
CacheConfiguration<Integer, String> configuration = CacheConfiguration
			.Builder(Integer.class, String.class, "my-cache", storageManager)
			.build(); 
Cache<Integer, String> cache = cacheManager.createCache("jCache", configuration);
```

If you prefer an external configuration, you can link the [storage configuration](/4.0/data-store/configuration.md#external-configuration):

{% tabs %}
{% tab title="cache-config.properties" %}

```
keyType = java.lang.Integer
valueType = java.lang.String

readThrough = true
writeThrough = true

storageConfigurationResourceName = microstream-storage.properties
```

{% endtab %}

{% tab title="microstream-storage.properties" %}

```
baseDirectory = ~/cache-data
channelCount = 4
```

{% endtab %}
{% endtabs %}

Or you can embed the storage configuration using the `storage.` prefix:

{% code title="cache-config.properties" %}

```
keyType = java.lang.Integer
valueType = java.lang.String

readThrough = true
writeThrough = true

storage.baseDirectory = ~/cache-data
storage.channelCount = 4
```

{% endcode %}

Spring example:

{% tabs %}
{% tab title="application.properties" %}

```
spring.jpa.properties.hibernate.cache.microstream.missing_cache_strategy = create
spring.jpa.properties.hibernate.cache.microstream.readThrough = true
spring.jpa.properties.hibernate.cache.microstreamwriteThrough = true
spring.jpa.properties.hibernate.cache.microstream.storage.baseDirectory = ~/cache-data
spring.jpa.properties.hibernate.cache.microstream.storage.channelCount = 4
spring.jpa.properties.hibernate.cache.region.factory_class = one.microstream.cache.hibernate.CacheRegionFactory
spring.jpa.properties.hibernate.cache.use_query_cache = true
spring.jpa.properties.hibernate.cache.use_second_level_cache = true
```

{% endtab %}

{% tab title="application.yml" %}

```yaml
spring:
    jpa:
        properties:
            hibernate:
                cache:
                    microstream:
                        missing_cache_strategy: create
                        readThrough: true
                        writeThrough: true
                        storage:
                            baseDirectory: ~/cache-data
                            channelCount: 4
                    region:
                        factory_class: one.microstream.cache.hibernate.CacheRegionFactory
                    use_query_cache: true
                    use_second_level_cache: true
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://manual.docs.microstream.one/4.0/cache/configuration/storage.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
