https://github.com/kilemonn/dcache
A dynamically configured multi-storage-medium backed caching framework for Spring.
https://github.com/kilemonn/dcache
cache cachemanager configuration-management dcache java jitpack kotlin spring
Last synced: 2 months ago
JSON representation
A dynamically configured multi-storage-medium backed caching framework for Spring.
- Host: GitHub
- URL: https://github.com/kilemonn/dcache
- Owner: Kilemonn
- License: apache-2.0
- Created: 2024-12-26T06:20:32.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-01-28T14:06:09.000Z (4 months ago)
- Last Synced: 2025-01-28T14:26:16.943Z (4 months ago)
- Topics: cache, cachemanager, configuration-management, dcache, java, jitpack, kotlin, spring
- Language: Kotlin
- Homepage:
- Size: 182 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DCache
[](https://github.com/Kilemonn/DCache/actions/workflows/gradle.yml) [](https://github.com/Kilemonn/DCache/actions/workflows/gradle.yml)## Overview
DCache is a property driven caching framework that allows you to configure multi-storage-medium backed caching framework for Spring.
Allowing you to simply define your preferred cache ID, backing mechanism, key and value types and just autowiring in the cache and using it.## Quick Start
Below are some quick start configuration snippets and matching code snippets.
### Example in [DCache-Example](https://github.com/Kilemonn/DCache-Example).
### More detailed documentation can be found in the [Wiki](https://github.com/Kilemonn/DCache/wiki)!
Including remote cache configuration and fallback cache configuration.### Including as a dependency
This can be included by making sure that you have [JitPack](https://jitpack.io) setup as a dependency repository within your project.
You can refer to the hosted versions of this library at [DCache](https://jitpack.io/#Kilemonn/DCache).Here is an example in Gradle to include the dependency:
```groovy
implementation("com.github.Kilemonn:dcache:0.1.0")
```### Defining cache instances
The cache instances are dynamically configured via the application properties.
The expected format is: `dcache.cache..=` where `cache-id` is an arbitrary id that you decide.For example defining an in memory cache with String as the key and String as the value, requires the following properties:
```properties
dcache.cache.my-in-memory-cache.type=IN_MEMORY
dcache.cache.my-in-memory-cache.key_class=java.lang.String
dcache.cache.my-in-memory-cache.value_class=java.lang.String
```In your application code you can auto wire this cache using the following code:
```java
public class YourClass {
@Autowired
@Qualifier("my-in-memory-cache")
private DCache cache;
}
```### Wiring in the cache manager
All the constructed caches are stored in the DCacheManager. This can be wired in as required.
The manager can be used to retrieve multiple cache instances by their ID.
For completeness see below:```java
public class YourClass {
@Autowired
private DCacheManager cacheManager;
}
```