(key string, timeUnit key.TimeUnit)
| 34 | } |
| 35 | |
| 36 | func (ac *AccessCache) Set(key string, timeUnit key.TimeUnit) error { |
| 37 | ttl, err := getCounterTtl(timeUnit) |
| 38 | if err != nil { |
| 39 | return err |
| 40 | } |
| 41 | |
| 42 | ctx, cancel := context.WithTimeout(context.Background(), ac.wt) |
| 43 | defer cancel() |
| 44 | err = ac.client.Set(ctx, key, true, ttl.Sub(time.Now())).Err() |
| 45 | if err != nil { |
| 46 | return err |
| 47 | } |
| 48 | |
| 49 | return nil |
| 50 | } |
| 51 | |
| 52 | func (ac *AccessCache) GetAccessStatus(key string) bool { |
| 53 | ctx, cancel := context.WithTimeout(context.Background(), ac.rt) |
nothing calls this directly
no test coverage detected