(ctx context.Context, key string, value any, ttl time.Duration)
| 98 | } |
| 99 | return false |
| 100 | } |
| 101 | |
| 102 | func (c *RuntimeCacheService) SetJSON(ctx context.Context, key string, value any, ttl time.Duration) { |
| 103 | if !c.Enabled() || strings.TrimSpace(key) == "" || value == nil || ttl <= 0 { |
| 104 | return |
| 105 | } |
| 106 | raw, err := json.Marshal(value) |
| 107 | if err != nil { |
| 108 | return |
| 109 | } |
| 110 | fullKey := c.key(key) |
| 111 | c.setMemory(fullKey, raw, ttl) |
| 112 | if c.client != nil { |
| 113 | _ = c.client.Set(ctx, fullKey, raw, ttl).Err() |
| 114 | } |
| 115 | } |
| 116 |