MicroStream Reference Manual
MicroStream HomeAPI Docs
4.0
4.0
  • Preface
  • System Requirements
  • License
  • Changelog
  • Installation
  • Data-Store
    • Overview
    • Getting Started
    • Root Instances
    • Configuration
      • Properties
      • Storage Files and Directories
      • Using Channels
      • Housekeeping
      • Backup
      • Lock File
    • Storage Targets
      • Local File System
      • SQL Databases
        • Oracle
        • MySQL
        • SQLite
      • Blob Stores
        • Oracle Cloud
        • Oracle NoSQL
        • Coherence
    • Storing Data
      • Convenience Methods and Explicit Storing (Transactions)
      • Lazy and Eager Storing
      • Transient Fields
      • Best Practice
    • Loading Data
      • Lazy Loading
        • Touched Timestamp, Null-Safe Variant
        • Clearing Lazy References
    • Deleting Data
    • Queries
    • Application Life-Cycle
    • Legacy Type Mapping
      • User Interaction
    • Backup Strategies
    • Import / Export
    • Housekeeping
    • Customizing
      • Custom Type Handler
      • Custom Legacy Type Handler
      • Custom Class Loader
      • Custom Storing Behavior
      • Optional Storage Manager Reference in Entities
    • REST Interface
      • Setup
      • REST API
      • Client GUI
    • FAQ
      • Data Model
      • Data Management
      • File Storage
      • Java Features
      • Miscellaneous
    • Addendum
      • Supported Java Features
      • Specialized Type Handlers
      • Examples and Demo Projects
  • Cache
    • Overview
    • Getting Started
    • Configuration
      • Properties
      • Storage
    • Use Cases
      • Hibernate Second Level Cache
      • Spring Cache
  • Basic Concepts
    • Layered Entities
      • Configuration
      • Defining Entities
      • Creating Entities
      • Updating Entities
      • Versioning
      • Logging
      • Multiple Layers
    • Wrapping
      • Configuration
      • Usage
Powered by GitBook
On this page
Export as PDF
  1. Cache
  2. Configuration

Storage

PreviousPropertiesNextUse Cases

Last updated 3 years ago

This is the manual for older MicroStream versions (Version < 5.0).

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

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.

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 :

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

readThrough = true
writeThrough = true

storageConfigurationResourceName = microstream-storage.properties
baseDirectory = ~/cache-data
channelCount = 4

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

cache-config.properties
keyType = java.lang.Integer
valueType = java.lang.String

readThrough = true
writeThrough = true

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

Spring example:

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
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
https://docs.microstream.one/
storage configuration