Skip to content

Commit

Permalink
Add deleteScanCount to improve performance on wildcard invalidation o…
Browse files Browse the repository at this point in the history
…f caches.
  • Loading branch information
dave08 committed Jun 4, 2024
1 parent 66d4ddf commit cc0da5a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group = "org.github.dave08.kacheable"
version = "0.1.2"
version = "0.1.4"

kotlin {
jvmToolchain(11)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import kotlin.time.Duration
class RedisKacheableStore(
private val conn: StatefulRedisConnection<String, String>,
private val deleteFromPatternInChunksOf: Int = 20,
private val deleteScanCount: Long = 1000,
) : KacheableStore {

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

ScanIterator.scan(commands, ScanArgs().match(key)).asSequence()
ScanIterator.scan(commands, ScanArgs().match(key).limit(deleteScanCount)).asSequence()
.chunked(deleteFromPatternInChunksOf)
.forEach { keys ->
if (keys.isNotEmpty()) commands.del(*(keys.toTypedArray()))
Expand Down

0 comments on commit cc0da5a

Please sign in to comment.