Skip to content

Commit

Permalink
Gjør det mulig å sette ttl i redis utenfor service klassene
Browse files Browse the repository at this point in the history
  • Loading branch information
b162214 committed Oct 18, 2023
1 parent 53fb672 commit f410d54
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class StatefullDataKanal(
override val eventName: EventName,
private val mainListener: River.PacketListener,
rapidsConnection: RapidsConnection,
val redisStore: IRedisStore
val redisStore: IRedisStore,
val ttl: Long = 60
) : DataKanal(
rapidsConnection
) {
Expand Down Expand Up @@ -59,7 +60,7 @@ class StatefullDataKanal(
}.forEach {
data ->
val str = if (data.second.isTextual) { data.second.asText() } else data.second.toString()
redisStore.set(message[Key.UUID.str].asText() + data.first, str)
redisStore.set(message[Key.UUID.str].asText() + data.first, str, ttl)
}
return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class StatefullEventListener(
override val event: EventName,
private val dataFelter: Array<String>,
private val mainListener: River.PacketListener,
rapidsConnection: RapidsConnection
rapidsConnection: RapidsConnection,
val ttl: Long = 60
) : EventListener(
rapidsConnection
) {
Expand All @@ -32,7 +33,7 @@ class StatefullEventListener(
Pair(dataFelt, packet[dataFelt])
}.forEach { data ->
val str = if (data.second.isTextual) { data.second.asText() } else data.second.toString()
redisStore.set(transactionId + data.first, str)
redisStore.set(transactionId + data.first, str, ttl)
}
}
override fun onEvent(packet: JsonMessage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import no.nav.helsearbeidsgiver.felles.toFeilMessage
import no.nav.helsearbeidsgiver.utils.log.sikkerLogger
import no.nav.helsearbeidsgiver.utils.pipe.orDefault

abstract class CompositeEventListener(open val redisStore: IRedisStore) : River.PacketListener {
abstract class CompositeEventListener(open val redisStore: IRedisStore, open val ttl: Long = 60) : River.PacketListener {

abstract val event: EventName
private lateinit var dataKanal: StatefullDataKanal
Expand Down Expand Up @@ -60,7 +60,7 @@ abstract class CompositeEventListener(open val redisStore: IRedisStore) : River.
?.asText()
.orDefault(transactionId)

redisStore.set(eventKey, clientId)
redisStore.set(eventKey, clientId, ttl)

Transaction.NEW
}
Expand Down

0 comments on commit f410d54

Please sign in to comment.