Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paging #611

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/.ci_test_and_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: zulu
java-version: 11
java-version: 17

- name: Upload Artifacts
run: ./gradlew publishAllPublicationsToMavenCentralRepository --no-daemon --no-parallel
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: zulu
java-version: 11
java-version: 17
- name: Run tests
run: ./gradlew check --rerun-tasks --stacktrace
- name: Upload code coverage
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ captures/

store/kover
*.podspec
yarn.lock
yarn.lock

*/kover
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("org.jlleitschuh.gradle.ktlint") version "11.0.0"
id("org.jlleitschuh.gradle.ktlint") version "12.1.0"
id("com.diffplug.spotless") version "6.4.1"
}

Expand Down Expand Up @@ -49,13 +49,13 @@ subprojects {
tasks {
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "11"
jvmTarget = "17"
}
}

withType<JavaCompile>().configureEach {
sourceCompatibility = JavaVersion.VERSION_11.name
targetCompatibility = JavaVersion.VERSION_11.name
sourceCompatibility = JavaVersion.VERSION_17.name
targetCompatibility = JavaVersion.VERSION_17.name
}
}

Expand Down
8 changes: 4 additions & 4 deletions cache/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ kotlin {
}
}

jvmToolchain(11)
jvmToolchain(17)
}

android {
Expand All @@ -92,16 +92,16 @@ android {
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}

tasks.withType<DokkaTask>().configureEach {
dokkaSourceSets.configureEach {
reportUndocumented.set(false)
skipDeprecated.set(true)
jdkVersion.set(8)
jdkVersion.set(17)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ interface Cache<Key : Any, Value : Any> {
* @throws UncheckedExecutionException If an unchecked exception was thrown while loading the value.
* @throws ExecutionError If an error was thrown while loading the value.
*/
fun getOrPut(key: Key, valueProducer: () -> Value): Value
fun getOrPut(
key: Key,
valueProducer: () -> Value,
): Value

/**
* @return Map of the [Value] associated with each [Key] in [keys]. Returned map only contains entries already present in the cache.
Expand All @@ -26,7 +29,10 @@ interface Cache<Key : Any, Value : Any> {
* If the cache previously contained a value associated with [key], the old value is replaced by [value].
* Prefer [getOrPut] when using the conventional "If cached, then return. Otherwise create, cache, and then return" pattern.
*/
fun put(key: Key, value: Value)
fun put(
key: Key,
value: Value,
)

/**
* Copies all of the mappings from the specified map to the cache. The effect of this call is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,52 @@ class CacheBuilder<Key : Any, Output : Any> {
internal var ticker: Ticker? = null
private set

fun concurrencyLevel(producer: () -> Int): CacheBuilder<Key, Output> = apply {
concurrencyLevel = producer.invoke()
}

fun maximumSize(maximumSize: Long): CacheBuilder<Key, Output> = apply {
if (maximumSize < 0) {
throw IllegalArgumentException("Maximum size must be non-negative.")
fun concurrencyLevel(producer: () -> Int): CacheBuilder<Key, Output> =
apply {
concurrencyLevel = producer.invoke()
}
this.maximumSize = maximumSize
}

fun expireAfterAccess(duration: Duration): CacheBuilder<Key, Output> = apply {
if (duration.isNegative()) {
throw IllegalArgumentException("Duration must be non-negative.")
fun maximumSize(maximumSize: Long): CacheBuilder<Key, Output> =
apply {
if (maximumSize < 0) {
throw IllegalArgumentException("Maximum size must be non-negative.")
}
this.maximumSize = maximumSize
}
expireAfterAccess = duration
}

fun expireAfterWrite(duration: Duration): CacheBuilder<Key, Output> = apply {
if (duration.isNegative()) {
throw IllegalArgumentException("Duration must be non-negative.")
fun expireAfterAccess(duration: Duration): CacheBuilder<Key, Output> =
apply {
if (duration.isNegative()) {
throw IllegalArgumentException("Duration must be non-negative.")
}
expireAfterAccess = duration
}
expireAfterWrite = duration
}

fun ticker(ticker: Ticker): CacheBuilder<Key, Output> = apply {
this.ticker = ticker
}
fun expireAfterWrite(duration: Duration): CacheBuilder<Key, Output> =
apply {
if (duration.isNegative()) {
throw IllegalArgumentException("Duration must be non-negative.")
}
expireAfterWrite = duration
}

fun weigher(maximumWeight: Long, weigher: Weigher<Key, Output>): CacheBuilder<Key, Output> = apply {
if (maximumWeight < 0) {
throw IllegalArgumentException("Maximum weight must be non-negative.")
fun ticker(ticker: Ticker): CacheBuilder<Key, Output> =
apply {
this.ticker = ticker
}

this.maximumWeight = maximumWeight
this.weigher = weigher
}
fun weigher(
maximumWeight: Long,
weigher: Weigher<Key, Output>,
): CacheBuilder<Key, Output> =
apply {
if (maximumWeight < 0) {
throw IllegalArgumentException("Maximum weight must be non-negative.")
}

this.maximumWeight = maximumWeight
this.weigher = weigher
}

fun build(): Cache<Key, Output> {
if (maximumSize != -1L && weigher != null) {
Expand Down
Loading
Loading