Documentation ¶
Index ¶
- type Cache
- type Error
- type Option
- func WithAddresses(masterName *string, redisAddress ...string) Option
- func WithConnectionStringOption(connectionString string) Option
- func WithDbNumber(dbNumber int) Option
- func WithLoggerOption(logger logger.Logger) Option
- func WithMaxRetry(maxRetry int) Option
- func WithMetricOption(metric metric.Metric) Option
- func WithTimeout(timeout time.Duration) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { // Ping // ICMP ping for checking connection // but be careful in some cases infrastructure filter ICMP packets for prevention of this protocol attacks Ping(ctx context.Context) error // GetKey // to read specific key from cache // method :: used for metrics // key :: the item which you wish to find in cache GetKey(ctx context.Context, method string, key string) (string, error) // Set // to store specified item with specified key and value in cache // method :: used for metrics // key, val :: specified key and corresponding value in cache Set(ctx context.Context, method string, key string, val string, expiration time.Duration) error //RemoveKey // to remove specific key from cache // method :: used for metrics // key :: the item which you wish to remove from the cache RemoveKey(ctx context.Context, method string, key string) error }
Cache this interface give us an abstraction over internal cache we are using currently the cache repo contains in-memory cache and redis cache which is a de-facto
func NewInMemoryCache ¶
func NewRedisCache ¶
NewRedisCache in order to use single redis, just give single address in redis addresses and for enabling redis sentinel mode, give cluster master-name and list of cluster members addresses
type Option ¶
func WithAddresses ¶
WithAddresses in order to use single instance give master name empty string, and redis addresses ad single item
func WithConnectionStringOption ¶
WithConnectionStringOption this model will configure redis in the way which we have a connection string and we have to pars this string and create redis options
func WithDbNumber ¶
func WithLoggerOption ¶
WithLoggerOption this option enables error logging on cache instance for you
func WithMaxRetry ¶
func WithMetricOption ¶
WithMetricOption this option allows you to define metric for your cache instance