You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Don't see your preferred implementation listed above?
41
48
Fear not, it is not difficult to create your own binding, and we'd be happy to accept it in a PR!
42
49
50
+
## Installation
51
+
52
+
We publish to [Maven Central](https://search.maven.org/search?q=g:io.github.xanthic.cache) and provide a convenient BOM (Build of Materials) to keep dependency versions in sync from the api to the provider.
53
+
54
+
Library developers only need to depend on the `cache-core` artifact, allowing application developers to specify which [provider](#supported-implementations) to use at runtime.
55
+
56
+
### Gradle (Kotlin)
57
+
58
+
```kotlin
59
+
repositories {
60
+
mavenCentral()
61
+
}
62
+
63
+
dependencies {
64
+
api(platform("io.github.xanthic.cache:cache-bom:0.1.0")) // Specify the latest version here
65
+
api(group ="io.github.xanthic.cache", name ="cache-core") // For library devs
66
+
implementation(group ="io.github.xanthic.cache", name ="cache-provider-caffeine") // For application devs; can select any provider
67
+
}
68
+
```
69
+
70
+
### Maven
71
+
72
+
```xml
73
+
<dependencyManagement>
74
+
<dependencies>
75
+
<dependency>
76
+
<groupId>io.github.xanthic.cache</groupId>
77
+
<artifactId>cache-bom</artifactId>
78
+
<!-- Specify the latest version here -->
79
+
<version>0.1.0</version>
80
+
<scope>import</scope>
81
+
<type>pom</type>
82
+
</dependency>
83
+
</dependencies>
84
+
</dependencyManagement>
85
+
86
+
<dependencies>
87
+
<!-- For library devs -->
88
+
<dependency>
89
+
<groupId>io.github.xanthic.cache</groupId>
90
+
<artifactId>cache-core</artifactId>
91
+
</dependency>
92
+
93
+
<!-- For application devs (can select any provider) -->
94
+
<dependency>
95
+
<groupId>io.github.xanthic.cache</groupId>
96
+
<artifactId>cache-provider-caffeine</artifactId>
97
+
</dependency>
98
+
</dependencies>
99
+
```
100
+
43
101
## Example Usage
44
102
45
-
Users should include at least one provider module in the runtime class-path.
103
+
Users should include at least one [provider](#supported-implementations) module in the runtime class-path.
46
104
Further, they can (optionally) do (but replace `CaffeineProvider` with the desired provider):
spec.maxSize(2048L); // setting a size constraint is highly recommended
57
-
spec.expiryTime(Duration.ofMinutes(5L));
58
-
spec.expiryType(ExpiryType.POST_ACCESS);
59
-
spec.removalListener((key, value, cause) -> {
60
-
if (cause.isEviction()) {
61
-
// do something
62
-
}
63
-
});
114
+
spec.maxSize(2048L); // setting a size constraint is highly recommended
115
+
spec.expiryTime(Duration.ofMinutes(5L));
116
+
spec.expiryType(ExpiryType.POST_ACCESS);
117
+
spec.removalListener((key, value, cause) -> {
118
+
if (cause.isEviction()) {
119
+
// do something
120
+
}
121
+
});
64
122
});
65
123
```
66
124
67
125
Here, the default provider will be used as `CacheBuilder#provider(CacheProvider)` was not called (note: this builder option is meant for end users rather than library devs).
68
126
69
127
Aside: the `removalListener` in the example above technically has no effect, but is included for illustration.
70
128
71
-
Note: Kotlin users can enjoy an [even cleaner](kotlin/src/test/kotlin/io/github/xanthic/cache/ktx/KotlinTest.kt) syntax via the extensions module!
72
-
73
-
## WIP
74
-
75
-
This API is still in alpha development stage. The current TODO list includes:
76
-
77
-
-[x] Add Javadocs
78
-
-[x] Incorporate logging (via SLF4J)
79
-
-[x] Create test suite (via JUnit)
80
-
-[ ] Consider if any more bindings should be added for initial release
81
-
-[ ] Eventually: Publish to Maven
129
+
Note: Kotlin users can enjoy an [even cleaner](kotlin/src/test/kotlin/io/github/xanthic/cache/ktx/KotlinTest.kt) syntax via the [extensions module](https://search.maven.org/search?q=g:io.github.xanthic.cache%20a:cache-kotlin)!
0 commit comments