Skip to content

Commit cc0da5a

Browse files
committed
Add deleteScanCount to improve performance on wildcard invalidation of caches.
1 parent 66d4ddf commit cc0da5a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
}
44

55
group = "org.github.dave08.kacheable"
6-
version = "0.1.2"
6+
version = "0.1.4"
77

88
kotlin {
99
jvmToolchain(11)

kacheable-lettuce/src/main/kotlin/com/github/dave08/kacheable/RedisKacheableStore.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import kotlin.time.Duration
1313
class RedisKacheableStore(
1414
private val conn: StatefulRedisConnection<String, String>,
1515
private val deleteFromPatternInChunksOf: Int = 20,
16+
private val deleteScanCount: Long = 1000,
1617
) : KacheableStore {
1718

1819
override suspend fun delete(key: String) {
@@ -21,7 +22,7 @@ class RedisKacheableStore(
2122
else withContext(Dispatchers.IO) {
2223
val commands = conn.sync()
2324

24-
ScanIterator.scan(commands, ScanArgs().match(key)).asSequence()
25+
ScanIterator.scan(commands, ScanArgs().match(key).limit(deleteScanCount)).asSequence()
2526
.chunked(deleteFromPatternInChunksOf)
2627
.forEach { keys ->
2728
if (keys.isNotEmpty()) commands.del(*(keys.toTypedArray()))

0 commit comments

Comments
 (0)