Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to use Redis 7.4 hash field TTL for presence #872

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/FZambia/statik v0.1.2-0.20180217151304-b9f012bb2a1b
github.com/FZambia/tarantool v0.3.1
github.com/FZambia/viper-lite v0.0.0-20220110144934-1899f66c7d0e
github.com/centrifugal/centrifuge v0.33.1-0.20240801054640-96afa7258679
github.com/centrifugal/centrifuge v0.33.2-0.20240807043159-8316026bacf3
github.com/centrifugal/protocol v0.13.4-0.20240702174651-e8db704aa2d2
github.com/cristalhq/jwt/v5 v5.4.0
github.com/gobwas/glob v0.2.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/centrifugal/centrifuge v0.33.1-0.20240801054640-96afa7258679 h1:KMAcBdIMWREsQmMG9v7CaxiItCXkchdd9zbRpM77XV4=
github.com/centrifugal/centrifuge v0.33.1-0.20240801054640-96afa7258679/go.mod h1:bZGDE9RBlZW8MSorwtT4Tl6KcrtbOtSbNYCn1j2Z8ow=
github.com/centrifugal/centrifuge v0.33.2-0.20240807043159-8316026bacf3 h1:OTNw4fHx/gttVX7iG/CPOcKoI9DoN3sJdvD0dTgYcpM=
github.com/centrifugal/centrifuge v0.33.2-0.20240807043159-8316026bacf3/go.mod h1:bZGDE9RBlZW8MSorwtT4Tl6KcrtbOtSbNYCn1j2Z8ow=
github.com/centrifugal/protocol v0.13.4-0.20240702174651-e8db704aa2d2 h1:U339eI0wzXpO5gRF43br85ZIxw061GHP0SZ7rjwOxiY=
github.com/centrifugal/protocol v0.13.4-0.20240702174651-e8db704aa2d2/go.mod h1:7V5vI30VcoxJe4UD87xi7bOsvI0bmEhvbQuMjrFM2L4=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
Expand Down
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ var defaults = map[string]any{
"global_history_meta_ttl": rule.DefaultGlobalHistoryMetaTTL,
"global_presence_ttl": 60 * time.Second,
"global_redis_presence_user_mapping": false,
"redis_presence_hash_field_ttl": false,

"allowed_delta_types": []centrifuge.DeltaType{},

Expand Down Expand Up @@ -2691,9 +2692,10 @@ func redisEngine(n *centrifuge.Node) (*centrifuge.RedisBroker, centrifuge.Presen
}

presenceManagerConfig := centrifuge.RedisPresenceManagerConfig{
Shards: redisShards,
Prefix: viper.GetString("redis_prefix"),
PresenceTTL: GetDuration("global_presence_ttl", true),
Shards: redisShards,
Prefix: viper.GetString("redis_prefix"),
PresenceTTL: GetDuration("global_presence_ttl", true),
UseHashFieldTTL: viper.GetBool("redis_presence_hash_field_ttl"),
}
if viper.GetBool("global_redis_presence_user_mapping") {
presenceManagerConfig.EnableUserMapping = func(_ string) bool {
Expand Down
Loading