all repos — myks @ ecfcd30b3ca1da06e8787d6d8813dc387c808ce3

A barebones in-memory keystore in 125~ lines of actual code.

handle negative cleanupIntervals
Marco Andronaco andronacomarco@gmail.com
Thu, 10 Oct 2024 09:05:53 +0200
commit

ecfcd30b3ca1da06e8787d6d8813dc387c808ce3

parent

74aa0b41cc5c88658e3cc38e7fd73e9cbe29cd7b

1 files changed, 2 insertions(+), 2 deletions(-)

jump to
M myks.gomyks.go

@@ -107,7 +107,7 @@ }

// StartCleanup starts a goroutine that periodically deletes all expired keys from the keystore. func (ks *KeyStore[T]) StartCleanup(cleanupInterval time.Duration) { - if cleanupInterval == 0 { + if cleanupInterval <= 0 { return }

@@ -131,7 +131,7 @@ func (ks *KeyStore[T]) StopCleanup() {

ks.mu.Lock() defer ks.mu.Unlock() - if ks.cleanupInterval != 0 { + if ks.cleanupInterval > 0 { close(ks.stopChan) ks.cleanupInterval = 0 }