Documentation ¶
Index ¶
- Constants
- type RedisStorage
- func (RedisStorage) CaddyModule() caddy.ModuleInfo
- func (rd RedisStorage) CertMagicStorage() (certmagic.Storage, error)
- func (rd *RedisStorage) DecryptStorageData(bytes []byte) (*StorageData, error)
- func (rd RedisStorage) Delete(key string) error
- func (rd *RedisStorage) EncryptStorageData(data *StorageData) ([]byte, error)
- func (rd RedisStorage) Exists(key string) bool
- func (rd *RedisStorage) GetAESKeyByte() []byte
- func (rd RedisStorage) List(prefix string, recursive bool) ([]string, error)
- func (rd RedisStorage) Load(key string) ([]byte, error)
- func (rd RedisStorage) Lock(ctx context.Context, key string) error
- func (rd *RedisStorage) Provision(ctx caddy.Context) error
- func (rd RedisStorage) Stat(key string) (certmagic.KeyInfo, error)
- func (rd RedisStorage) Store(key string, value []byte) error
- func (rd RedisStorage) Unlock(key string) error
- func (rd *RedisStorage) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- type StorageData
Constants ¶
View Source
const ( // InactiveLockDuration is when the lock is considered as stale and need to be refreshed InactiveLockDuration = 4 * time.Hour // LockDuration is lock time duration LockDuration = 8 * time.Hour // ScanCount is how many scan command might return ScanCount int64 = 100 // DefaultAESKey needs to be 32 bytes long DefaultAESKey = "redistls-01234567890-caddytls-32" // DefaultKeyPrefix defines the default prefix in KV store DefaultKeyPrefix = "caddytls" // DefaultValuePrefix sets a prefix to KV values to check validation DefaultValuePrefix = "caddy-storage-redis" // DefaultRedisHost define the Redis instance host DefaultRedisHost = "127.0.0.1" // DefaultRedisPort define the Redis instance port DefaultRedisPort = "6379" // DefaultRedisDB define the Redis DB number DefaultRedisDB = 0 // DefaultRedisPassword define the Redis instance password, if any DefaultRedisPassword = "" // DefaultRedisTimeout define the Redis wait time in (s) DefaultRedisTimeout = 5 // DefaultRedisTLS define the Redis TLS connection DefaultRedisTLS = false // DefaultRedisTLSInsecure define the Redis TLS connection DefaultRedisTLSInsecure = true // EnvNameRedisHost defines the env variable name to override Redis host EnvNameRedisHost = "CADDY_CLUSTERING_REDIS_HOST" // EnvNameRedisPort defines the env variable name to override Redis port EnvNameRedisPort = "CADDY_CLUSTERING_REDIS_PORT" // EnvNameRedisDB defines the env variable name to override Redis db number EnvNameRedisDB = "CADDY_CLUSTERING_REDIS_DB" // EnvNameRedisPassword defines the env variable name to override Redis password EnvNameRedisPassword = "CADDY_CLUSTERING_REDIS_PASSWORD" // EnvNameRedisTimeout defines the env variable name to override Redis wait timeout for dial, read, write EnvNameRedisTimeout = "CADDY_CLUSTERING_REDIS_TIMEOUT" // EnvNameAESKey defines the env variable name to override AES key EnvNameAESKey = "CADDY_CLUSTERING_REDIS_AESKEY" // EnvNameKeyPrefix defines the env variable name to override KV key prefix EnvNameKeyPrefix = "CADDY_CLUSTERING_REDIS_KEYPREFIX" // EnvNameValuePrefix defines the env variable name to override KV value prefix EnvNameValuePrefix = "CADDY_CLUSTERING_REDIS_VALUEPREFIX" // EnvNameTLSEnabled defines the env variable name to whether enable Redis TLS Connection or not EnvNameTLSEnabled = "CADDY_CLUSTERING_REDIS_TLS" // EnvNameTLSInsecure defines the env variable name to whether verify Redis TLS Connection or not EnvNameTLSInsecure = "CADDY_CLUSTERING_REDIS_TLS_INSECURE" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RedisStorage ¶
type RedisStorage struct { Client *redis.Client ClientLocker *redislock.Client Logger *zap.SugaredLogger Address string `json:"address"` Host string `json:"host"` Port string `json:"port"` DB int `json:"db"` Password string `json:"password"` Timeout int `json:"timeout"` KeyPrefix string `json:"key_prefix"` ValuePrefix string `json:"value_prefix"` AesKey string `json:"aes_key"` TlsEnabled bool `json:"tls_enabled"` TlsInsecure bool `json:"tls_insecure"` // contains filtered or unexported fields }
RedisStorage contain Redis client, and plugin option
func (RedisStorage) CaddyModule ¶
func (RedisStorage) CaddyModule() caddy.ModuleInfo
register caddy module with ID caddy.storage.redis
func (RedisStorage) CertMagicStorage ¶
func (rd RedisStorage) CertMagicStorage() (certmagic.Storage, error)
CertMagicStorage converts s to a certmagic.Storage instance.
func (*RedisStorage) DecryptStorageData ¶
func (rd *RedisStorage) DecryptStorageData(bytes []byte) (*StorageData, error)
DecryptStorageData decrypt storage data, so we can read it
func (*RedisStorage) EncryptStorageData ¶
func (rd *RedisStorage) EncryptStorageData(data *StorageData) ([]byte, error)
EncryptStorageData encrypt storage data, so it won't be plain data
func (RedisStorage) Exists ¶
func (rd RedisStorage) Exists(key string) bool
Exists returns true if the key exists
func (*RedisStorage) GetAESKeyByte ¶
func (rd *RedisStorage) GetAESKeyByte() []byte
func (RedisStorage) List ¶
func (rd RedisStorage) List(prefix string, recursive bool) ([]string, error)
List returns all keys that match prefix.
func (RedisStorage) Load ¶
func (rd RedisStorage) Load(key string) ([]byte, error)
Load retrieves the value at key.
func (RedisStorage) Lock ¶
func (rd RedisStorage) Lock(ctx context.Context, key string) error
Lock is to lock value
func (*RedisStorage) Provision ¶
func (rd *RedisStorage) Provision(ctx caddy.Context) error
func (RedisStorage) Stat ¶
func (rd RedisStorage) Stat(key string) (certmagic.KeyInfo, error)
Stat returns information about key.
func (RedisStorage) Store ¶
func (rd RedisStorage) Store(key string, value []byte) error
Store values at key
func (RedisStorage) Unlock ¶
func (rd RedisStorage) Unlock(key string) error
Unlock is to unlock value
func (*RedisStorage) UnmarshalCaddyfile ¶
func (rd *RedisStorage) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
type StorageData ¶
StorageData describe the data that is stored in KV storage
Click to show internal directories.
Click to hide internal directories.