snapshot of https://github.com/livekit/livekit.git @ 08c5433449c106943231037d0b892895f6e92d3b (2026-09-15)
Some checks failed
Release to Docker / docker (push) Failing after 2s
Release Test Server to Docker / docker (push) Failing after 3s
Test / test (push) Failing after 16s

This commit is contained in:
upstream-mirror
2026-09-15 16:14:22 +05:00
commit 78704103fc
422 changed files with 154805 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
package utils
import (
"time"
"github.com/jellydator/ttlcache/v3"
"github.com/livekit/protocol/livekit"
)
const (
iceConfigTTLMin = 5 * time.Minute
)
type IceConfigCache[T comparable] struct {
c *ttlcache.Cache[T, *livekit.ICEConfig]
}
func NewIceConfigCache[T comparable](ttl time.Duration) *IceConfigCache[T] {
cache := ttlcache.New(
ttlcache.WithTTL[T, *livekit.ICEConfig](max(ttl, iceConfigTTLMin)),
ttlcache.WithDisableTouchOnHit[T, *livekit.ICEConfig](),
)
go cache.Start()
return &IceConfigCache[T]{cache}
}
func (icc *IceConfigCache[T]) Stop() {
icc.c.Stop()
}
func (icc *IceConfigCache[T]) Put(key T, iceConfig *livekit.ICEConfig) {
icc.c.Set(key, iceConfig, ttlcache.DefaultTTL)
}
func (icc *IceConfigCache[T]) Get(key T) *livekit.ICEConfig {
if it := icc.c.Get(key); it != nil {
return it.Value()
}
return &livekit.ICEConfig{}
}