@@ -26,8 +26,6 @@ const (
26
26
HazelcastType = "hazelcast"
27
27
// HazelcastTagPattern represents the tag pattern to be used as a key in specified storage
28
28
HazelcastTagPattern = "gocache_tag_%s"
29
-
30
- TagKeyExpiry = 720 * time .Hour
31
29
)
32
30
33
31
// HazelcastStore is a store for Hazelcast
@@ -76,12 +74,12 @@ func (s *HazelcastStore) Set(ctx context.Context, key any, value any, options ..
76
74
return err
77
75
}
78
76
if tags := opts .Tags ; len (tags ) > 0 {
79
- s .setTags (ctx , s .hzMap , key , tags )
77
+ s .setTags (ctx , s .hzMap , key , tags , opts . TagsTTL )
80
78
}
81
79
return nil
82
80
}
83
81
84
- func (s * HazelcastStore ) setTags (ctx context.Context , hzMap HazelcastMapInterface , key any , tags []string ) {
82
+ func (s * HazelcastStore ) setTags (ctx context.Context , hzMap HazelcastMapInterface , key any , tags []string , ttl time. Duration ) {
85
83
group , ctx := errgroup .WithContext (ctx )
86
84
for _ , tag := range tags {
87
85
currentTag := tag
@@ -91,18 +89,20 @@ func (s *HazelcastStore) setTags(ctx context.Context, hzMap HazelcastMapInterfac
91
89
if err != nil {
92
90
return err
93
91
}
94
- if tagValue == nil {
95
- return hzMap .SetWithTTL (ctx , tagKey , key .(string ), TagKeyExpiry )
96
- }
97
- cacheKeys := strings .Split (tagValue .(string ), "," )
98
- for _ , cacheKey := range cacheKeys {
99
- if key == cacheKey {
100
- return nil
92
+
93
+ newTagValue := key .(string )
94
+ if tagValue != nil {
95
+ cacheKeys := strings .Split (tagValue .(string ), "," )
96
+ for _ , cacheKey := range cacheKeys {
97
+ if key == cacheKey {
98
+ return nil
99
+ }
101
100
}
101
+ cacheKeys = append (cacheKeys , key .(string ))
102
+ newTagValue = strings .Join (cacheKeys , "," )
102
103
}
103
- cacheKeys = append (cacheKeys , key .(string ))
104
- newTagValue := strings .Join (cacheKeys , "," )
105
- return hzMap .SetWithTTL (ctx , tagKey , newTagValue , TagKeyExpiry )
104
+
105
+ return hzMap .SetWithTTL (ctx , tagKey , newTagValue , ttl )
106
106
})
107
107
}
108
108
group .Wait ()
0 commit comments