Documentation ¶
Index ¶
- func GetRedisCachePrefix() string
- func InitMemoryConn(config MemoryConfig) *badger.DB
- func InitMongoMasterConn(config MongoConfig) (*mongo.Client, string)
- func InitMongoTenantConns(config MongoConfig, master *gorm.DB, ...) (map[uint64]*mongo.Client, map[uint64]string)
- func InitMysqlMasterConn(config SQLConfig) (*gorm.DB, string)
- func InitMysqlTenantConns(config SQLConfig, master *gorm.DB, ...) (map[uint64]*gorm.DB, map[uint64]string)
- func InitRedisMasterConn(config RedisConfig) map[uint64]*RedisDBConn
- func InitRedisTenantConns(config RedisConfig, master *gorm.DB, ...) map[uint64]*RedisDBConn
- func MemoryDelKey(client *badger.DB, key string) error
- func MemoryGetBytes(client *badger.DB, key string) ([]byte, error)
- func MemoryGetString(client *badger.DB, key string) (string, error)
- func MemorySetBytes(client *badger.DB, key string, val []byte, ttl time.Duration) error
- func MemorySetString(client *badger.DB, key string, val string, ttl time.Duration) error
- func RedisDelKey(c context.Context, clients *RedisDBConn, keys ...string) error
- func RedisExpireKey(c context.Context, clients *RedisDBConn, key string, ttl time.Duration) error
- func RedisGetLRange(c context.Context, clients *RedisDBConn, key string, start, stop int64) ([]string, error)
- func RedisGetString(c context.Context, clients *RedisDBConn, key string) (string, error)
- func RedisHGet(c context.Context, clients *RedisDBConn, key string, field string) (string, error)
- func RedisHSet(c context.Context, clients *RedisDBConn, key string, field string, ...) error
- func RedisHgets(c context.Context, clients *RedisDBConn, redisKeysWithField map[string]string) (map[string]string, error)
- func RedisIncrementValue(c context.Context, clients *RedisDBConn, key string) error
- func RedisIsKeyExists(c context.Context, clients *RedisDBConn, key string) (bool, error)
- func RedisMGet(c context.Context, clients *RedisDBConn, keys ...string) ([]interface{}, error)
- func RedisRPush(c context.Context, clients *RedisDBConn, key string, valueList []string) error
- func RedisSAdd(c context.Context, clients *RedisDBConn, key string, elements interface{}) error
- func RedisSIsMember(c context.Context, clients *RedisDBConn, key string, element interface{}) (bool, error)
- func RedisSMembers(c context.Context, clients *RedisDBConn, key string) ([]string, error)
- func RedisSRandMemberN(c context.Context, clients *RedisDBConn, key string, count int64) ([]string, error)
- func RedisSRem(c context.Context, clients *RedisDBConn, key string, elements interface{}) error
- func RedisSet(c context.Context, clients *RedisDBConn, key string, data interface{}, ...) error
- func RedisSetJSON(c context.Context, clients *RedisDBConn, key string, data interface{}, ...) error
- type FieldValuePair
- type KeyFieldPair
- type MemoryConfig
- type MongoConfig
- type RedisConfig
- type RedisDBConn
- type SQLConfig
- type TenantConnections
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRedisCachePrefix ¶
func GetRedisCachePrefix() string
func InitMemoryConn ¶ added in v1.1.42
func InitMemoryConn(config MemoryConfig) *badger.DB
Initialize the Memory database.
func InitMongoMasterConn ¶
func InitMongoMasterConn(config MongoConfig) (*mongo.Client, string)
func InitMongoTenantConns ¶
func InitMongoTenantConns(config MongoConfig, master *gorm.DB, tenantAlterDbHostParam, tenantDBPassPhraseKey string) (map[uint64]*mongo.Client, map[uint64]string)
Init the mongo database connection map.
func InitMysqlMasterConn ¶
InitMysqlMasterConn returns mysql master db connection.
func InitMysqlTenantConns ¶
func InitRedisMasterConn ¶
func InitRedisMasterConn(config RedisConfig) map[uint64]*RedisDBConn
func InitRedisTenantConns ¶
func InitRedisTenantConns(config RedisConfig, master *gorm.DB, tenantAlterDbHostParam, tenantDBPassPhraseKey string) map[uint64]*RedisDBConn
func MemoryDelKey ¶ added in v1.1.44
MemoryDelKey will just delete a key from memory if it is exist.
func MemoryGetBytes ¶ added in v1.1.42
MemoryGetBytes returns a byte val of associated key from memory. If the key doesn't exist in memory then this function will return `nil` error with empty byte slice.
func MemoryGetString ¶ added in v1.1.42
MemoryGetString returns a string val of associated key from memory. If the key doesn't exist in memory then this function will return `nil` error with empty string.
func MemorySetBytes ¶ added in v1.1.42
MemorySetBytes saves a string key and it's value in bytes into memory. If you supply `ttl` greater than 0 then this will save the key into the memory for that many seconds. Once the TTL has elapsed, the key will no longer be retrievable and will be eligible for garbage collection. Pass `ttl` as 0 if you want to keep the key forever into the db until the server restarted or crashed.
func MemorySetString ¶ added in v1.1.42
MemorySetString saves a string key value pair into memory. If you supply `ttl` greater than 0 then this will save the key into the memory for that many seconds. Once the TTL has elapsed, the key will no longer be retrievable and will be eligible for garbage collection. Pass `ttl` as 0 if you want to keep the key forever into the db until the server restarted or crashed.
func RedisDelKey ¶ added in v1.1.17
func RedisDelKey(c context.Context, clients *RedisDBConn, keys ...string) error
func RedisExpireKey ¶ added in v1.1.28
func RedisGetLRange ¶ added in v1.1.17
func RedisGetString ¶ added in v1.1.17
func RedisHgets ¶ added in v1.1.33
func RedisHgets(c context.Context, clients *RedisDBConn, redisKeysWithField map[string]string) (map[string]string, error)
To get one field from multiple redis hashes in one call to redis. Input is a map of keys and the respective field for those keys. Output is a map of keys and the respective values for those keys in redis.
func RedisIncrementValue ¶ added in v1.1.17
func RedisIncrementValue(c context.Context, clients *RedisDBConn, key string) error
func RedisIsKeyExists ¶ added in v1.1.41
func RedisMGet ¶ added in v1.1.17
func RedisMGet(c context.Context, clients *RedisDBConn, keys ...string) ([]interface{}, error)
func RedisRPush ¶ added in v1.1.17
func RedisSAdd ¶ added in v1.1.17
func RedisSAdd(c context.Context, clients *RedisDBConn, key string, elements interface{}) error
func RedisSIsMember ¶ added in v1.1.17
func RedisSMembers ¶ added in v1.1.17
func RedisSRandMemberN ¶ added in v1.1.41
func RedisSRem ¶ added in v1.1.17
func RedisSRem(c context.Context, clients *RedisDBConn, key string, elements interface{}) error
func RedisSetJSON ¶ added in v1.1.17
Types ¶
type FieldValuePair ¶ added in v1.1.33
type KeyFieldPair ¶ added in v1.1.33
type MemoryConfig ¶ added in v1.1.42
type MongoConfig ¶
type RedisConfig ¶
type RedisDBConn ¶ added in v1.1.17
IMPORTANT: This structure is holding any kind of redis connection using a map in bean.go.
type TenantConnections ¶
type TenantConnections struct { ID uint64 `gorm:"primary_key;AUTO_INCREMENT;column:Id"` UUID string `gorm:"type:CHAR(36);not null;unique;column:Uuid"` TenantID uint64 `gorm:"not null;column:TenantId"` Code string `gorm:"type:VARCHAR(20);not null;unique;column:Code"` Connections datatypes.JSON `gorm:"not null;column:Connections"` CreatedBy uint64 `gorm:"not null;default:0;column:CreatedBy"` UpdatedBy uint64 `gorm:"not null;default:0;column:UpdatedBy"` DeletedBy uint64 `gorm:"default:NULL;column:DeletedBy"` CreatedAt time.Time `gorm:"type:timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP;column:CreatedAt"` UpdatedAt time.Time `gorm:"type:timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;column:UpdatedAt"` DeletedAt gorm.DeletedAt `gorm:"type:timestamp NULL DEFAULT NULL;column:DeletedAt"` }
TenantConnections represent a tenant database configuration record in master database
func GetAllTenantCfgs ¶
func GetAllTenantCfgs(db *gorm.DB) []*TenantConnections
GetAllTenantCfgs return all Tenant data from master db.
func (TenantConnections) TableName ¶
func (TenantConnections) TableName() string