cache.go 419 B

1234567891011121314151617181920212223
  1. package cache
  2. import (
  3. "context"
  4. "errors"
  5. "time"
  6. )
  7. var (
  8. ErrorCache = errors.New("cache error")
  9. ErrorCacheNotFound = errors.New("cache not found")
  10. )
  11. var (
  12. Redis = "redis"
  13. Memory = "memory"
  14. )
  15. type Cache interface {
  16. Set(ctx context.Context, key, val string, t time.Duration) (bool, error)
  17. Get(ctx context.Context, key string) (string, error)
  18. Delete(ctx context.Context, key string) (bool, error)
  19. }