MicroStream Reference Manual
MicroStream HomeAPI Docs
3.0
3.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
    • 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

Configuration

PreviousGetting StartedNextProperties

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:

The default way to configure a JCache provider is to use the classjavax.cache.configuration.MutableConfiguration. This is mostly used to avoid provider specific code.

If you want to use all of MicroStream's Cache features, you can use our configuration implementation: one.microstream.cache.CacheConfiguration

CachingProvider provider     = Caching.getCachingProvider();  
CacheManager    cacheManager = provider.getCacheManager();   
CacheConfiguration<Integer, String> configuration = CacheConfiguration
			.Builder(Integer.class, String.class)
			.storeByValue()
			.expiryPolicyFactory(CreatedExpiryPolicy.factoryOf(Duration.ONE_MINUTE))
			.build(); 
Cache<Integer, String> cache = cacheManager.createCache("jCache", configuration); 
cache.put(1, "Hello World"); 
String value = cache.get(1); 

To read an external configuration use CacheConfigurationLoader and CacheConfigurationParser or the Load*() methods of CacheConfiguration.

CacheConfiguration<Integer, String> configuration = CacheConfiguration
			.Load("cache-config.properties", Integer.class, String.class);

If you just use CacheConfiguration.Load() the default configuration file is used, which is either a file in the classpath root named microstream-cache.properties, or the path configured via the system property microstream.cache.configuration.path.

https://docs.microstream.one/