Get retrieves an entry from the cache based on the provided key. Parameters: - ctx: The context for the operation. - key: The cache key to retrieve. - data: The variable to store the retrieved data. Returns an error if the key does not exist or if the retrieval fails.
(ctx context.Context, key string, data interface{})
| 137 | // - data: The variable to store the retrieved data. |
| 138 | // Returns an error if the key does not exist or if the retrieval fails. |
| 139 | func (r *RedisCache) Get(ctx context.Context, key string, data interface{}) error { |
| 140 | err := r.cache.Get(ctx, key, &data) |
| 141 | if errors.Is(err, cache.ErrCacheMiss) { |
| 142 | return nil // Return nil if the cache key was not found (cache miss) |
| 143 | } |
| 144 | |
| 145 | return err |
| 146 | } |
| 147 | |
| 148 | // Delete removes an entry from the cache based on the provided key. |
| 149 | // Parameters: |