Documentation ¶
Index ¶
- Constants
- func New(databaseType int) func(databaseCompany int, config *Config) interface{}
- func NewCaching(databaseCompany int, config *Config) interface{}
- func NewNoSQL(databaseCompany int, config *Config) interface{}
- func NewSQL(databaseCompany int, config *Config) interface{}
- type BigCacheClient
- func (bc *BigCacheClient) Append(key string, value interface{}) error
- func (bc *BigCacheClient) Close() error
- func (bc *BigCacheClient) Delete(key string) error
- func (bc *BigCacheClient) Get(key string) (interface{}, error)
- func (bc *BigCacheClient) GetCapacity() (interface{}, error)
- func (bc *BigCacheClient) GetNumberOfRecords() int
- func (bc *BigCacheClient) Middleware(hash hash.IHash) echo.MiddlewareFunc
- func (bc *BigCacheClient) Set(key string, value interface{}, expire time.Duration) error
- func (bc *BigCacheClient) Update(key string, value interface{}, expire time.Duration) error
- type ComparisonOperators
- type Config
- type CustomCache
- type CustomClient
- func (cl *CustomClient) Close() error
- func (cl *CustomClient) Delete(key string) error
- func (cl *CustomClient) Get(key string) (interface{}, error)
- func (cl *CustomClient) GetCapacity() (interface{}, error)
- func (cl *CustomClient) GetMany(keys []string) (map[string]interface{}, []string, error)
- func (cl *CustomClient) GetNumberOfRecords() int
- func (cl *CustomClient) Middleware(hash hash.IHash) echo.MiddlewareFunc
- func (cl *CustomClient) Range(f func(key, value interface{}) bool)
- func (cl *CustomClient) Set(key string, value interface{}, expire time.Duration) error
- func (cl *CustomClient) Update(key string, value interface{}, expire time.Duration) error
- type ICaching
- type INoSQL
- type ISQL
- type LIKE
- type Lookup
- type Match
- type MatchLookup
- type MongoClient
- func (m *MongoClient) Create(databaseName, collectionName string, dataModel interface{}) (result interface{}, err error)
- func (m *MongoClient) Delete(databaseName, collectionName, ID string) (result interface{}, err error)
- func (m *MongoClient) GetALL(databaseName, collectionName, lastID, pageSize string, dataModel reflect.Type) (results interface{}, err error)
- func (m *MongoClient) GetByField(databaseName, collectionName, field, value string, dataModel reflect.Type) (result interface{}, err error)
- func (m *MongoClient) MatchAndLookup(databaseName, collectionName string, model MatchLookup, dataModel reflect.Type) (results interface{}, err error)
- func (m *MongoClient) Update(databaseName, collectionName, ID string, dataModel interface{}) (result interface{}, err error)
- type MongoDB
- type Redis
- type RedisClient
- func (r *RedisClient) Append(key string, value interface{}) error
- func (r *RedisClient) Close() error
- func (r *RedisClient) Delete(key string) error
- func (r *RedisClient) Get(key string) (interface{}, error)
- func (r *RedisClient) GetCapacity() (interface{}, error)
- func (r *RedisClient) GetNumberOfRecords() int
- func (r *RedisClient) Middleware(hash hash.IHash) echo.MiddlewareFunc
- func (r *RedisClient) Set(key string, value interface{}, expire time.Duration) error
- func (r *RedisClient) Update(key string, value interface{}, expire time.Duration) error
- type SQLLikeClient
- type Set
- type UpdateOperators
Constants ¶
const ( // CUSTOM caching on local memory CUSTOM = iota // BIGCACHE database BIGCACHE // REDIS database REDIS )
const ( // SQL database SQL = iota // NOSQL database NOSQL // CACHING databse CACHING )
const ( // MONGODB database MONGODB = iota )
const ( // SQLLike database (common relational database) SQLLike = iota )
Variables ¶
This section is empty.
Functions ¶
func NewCaching ¶
NewCaching factory pattern
Types ¶
type BigCacheClient ¶
type BigCacheClient struct {
Client *bigcache.BigCache
}
BigCacheClient manage all BigCache actions
func (*BigCacheClient) Append ¶
func (bc *BigCacheClient) Append(key string, value interface{}) error
Append new value base on the key provide, With Append() you can concatenate multiple entries under the same key in an lock optimized way.
func (*BigCacheClient) Close ¶
func (bc *BigCacheClient) Close() error
Close function will close BigCache connection
func (*BigCacheClient) Delete ¶
func (bc *BigCacheClient) Delete(key string) error
Delete function will delete value based on the key provided
func (*BigCacheClient) Get ¶
func (bc *BigCacheClient) Get(key string) (interface{}, error)
Get return value based on the key provided
func (*BigCacheClient) GetCapacity ¶
func (bc *BigCacheClient) GetCapacity() (interface{}, error)
GetCapacity method return redis database size
func (*BigCacheClient) GetNumberOfRecords ¶
func (bc *BigCacheClient) GetNumberOfRecords() int
GetNumberOfRecords return number of records
func (*BigCacheClient) Middleware ¶
func (bc *BigCacheClient) Middleware(hash hash.IHash) echo.MiddlewareFunc
Middleware for echo framework
type ComparisonOperators ¶
type ComparisonOperators string
ComparisonOperators mongodb comparition operation type
const ( Equal ComparisonOperators = "$eq" EqualAny ComparisonOperators = "$in" NotEqual ComparisonOperators = "$ne" NotEqualAnyLL ComparisonOperators = "$nin" GreaterThan ComparisonOperators = "$gt" GreaterThanOrEqualTo ComparisonOperators = "$gte" LessThan ComparisonOperators = "$lt" LessThanOrEqualTo ComparisonOperators = "$lte" )
This is for mongodb comparition operation constant
type Config ¶
type Config struct { LIKE LIKE `json:"like"` MongoDB MongoDB `json:"mongodb"` Redis Redis `json:"redis,omitempty"` CustomCache CustomCache `json:"customCache,omitempty"` BigCache bigcache.Config `json:"bigCache,omitempty"` }
Config model for database config
type CustomCache ¶
type CustomCache struct { CacheSize int64 `json:"cacheSize,omitempty"` // byte CleaningEnable bool `json:"cleaningEnable,omitempty"` CleaningInterval time.Duration `json:"cleaningInterval,omitempty"` // nanosecond }
CustomCache config model
type CustomClient ¶
type CustomClient struct {
// contains filtered or unexported fields
}
CustomClient manage all custom caching actions
func (*CustomClient) Close ¶
func (cl *CustomClient) Close() error
Close closes the cache and frees up resources.
func (*CustomClient) Delete ¶
func (cl *CustomClient) Delete(key string) error
Delete deletes the key and its value from the cache.
func (*CustomClient) Get ¶
func (cl *CustomClient) Get(key string) (interface{}, error)
Get return value based on the key provided
func (*CustomClient) GetCapacity ¶
func (cl *CustomClient) GetCapacity() (interface{}, error)
GetCapacity method return redis database size
func (*CustomClient) GetMany ¶
func (cl *CustomClient) GetMany(keys []string) (map[string]interface{}, []string, error)
GetMany return value based on the list of keys provided
func (*CustomClient) GetNumberOfRecords ¶
func (cl *CustomClient) GetNumberOfRecords() int
GetNumberOfRecords return number of records
func (*CustomClient) Middleware ¶
func (cl *CustomClient) Middleware(hash hash.IHash) echo.MiddlewareFunc
Middleware for echo framework
func (*CustomClient) Range ¶
func (cl *CustomClient) Range(f func(key, value interface{}) bool)
Range over linear data structure
type ICaching ¶
type ICaching interface { Middleware(hash hash.IHash) echo.MiddlewareFunc Get(key string) (interface{}, error) Set(key string, value interface{}, expire time.Duration) error Update(key string, value interface{}, expire time.Duration) error Delete(key string) error GetNumberOfRecords() int GetCapacity() (interface{}, error) Close() error }
ICaching caching factory pattern interface
type INoSQL ¶
type INoSQL interface { GetALL( databaseName, collectionName, lastID, pageSize string, dataModel reflect.Type) (results interface{}, err error) GetByField( databaseName, collectionName, field, value string, dataModel reflect.Type) (interface{}, error) Create( databaseName, collectionName string, dataModel interface{}) (result interface{}, err error) Update( databaseName, collectionName, ID string, dataModel interface{}) (result interface{}, err error) Delete( databaseName, collectionName, ID string) (result interface{}, err error) MatchAndLookup( databaseName, collectionName string, model MatchLookup, dataModel reflect.Type) (results interface{}, err error) }
INoSQL factory pattern interface
type LIKE ¶
type LIKE struct { DriverName string `json:"driverName"` DataSourceName string `json:"dataSourceName"` MaxConnectionLifetime time.Duration `json:"maxConnectionLifetime"` MaxConnectionIdle int `json:"maxConnectionIdle"` MaxConnectionOpen int `json:"maxConnectionOpen"` }
LIKE model for SQL-LIKE connection config
type Lookup ¶
type Lookup struct { From string `json:"From"` LocalField string `json:"localField"` ForeignField string `json:"foreignField"` As string `json:"as"` }
Lookup mongo model
type Match ¶
type Match struct { Field string `json:"field"` Operator ComparisonOperators `json:"operator"` Value string `json:"value"` }
Match mongo model
type MatchLookup ¶
MatchLookup mongo model
type MongoClient ¶
MongoClient manage all mongodb actions
func (*MongoClient) Create ¶
func (m *MongoClient) Create( databaseName, collectionName string, dataModel interface{}) (result interface{}, err error)
Create new record base on model
func (*MongoClient) Delete ¶
func (m *MongoClient) Delete( databaseName, collectionName, ID string) (result interface{}, err error)
Delete record base on _id
func (*MongoClient) GetALL ¶
func (m *MongoClient) GetALL( databaseName, collectionName, lastID, pageSize string, dataModel reflect.Type) (results interface{}, err error)
GetALL from collection with pagination
func (*MongoClient) GetByField ¶
func (m *MongoClient) GetByField( databaseName, collectionName, field, value string, dataModel reflect.Type) (result interface{}, err error)
GetByField base on field and value
func (*MongoClient) MatchAndLookup ¶
func (m *MongoClient) MatchAndLookup( databaseName, collectionName string, model MatchLookup, dataModel reflect.Type) (results interface{}, err error)
MatchAndLookup ...
func (*MongoClient) Update ¶
func (m *MongoClient) Update( databaseName, collectionName, ID string, dataModel interface{}) (result interface{}, err error)
Update record with new value base on _id and model
type MongoDB ¶
type MongoDB struct { User string `json:"user"` Password string `json:"password"` Hosts []string `json:"hosts"` DB string `json:"db"` Options []string `json:"options"` }
MongoDB model for MongoDB connection config
type Redis ¶
type Redis struct { Password string `json:"password,omitempty"` Host string `json:"host,omitempty"` DB int `json:"db,omitempty"` MaxRetries int `json:"maxRetries,omitempty"` }
Redis model for redis config
type RedisClient ¶
RedisClient manage all redis actions
func (*RedisClient) Append ¶
func (r *RedisClient) Append(key string, value interface{}) error
Append new value over the key provided
func (*RedisClient) Close ¶
func (r *RedisClient) Close() error
Close method will close redis connection
func (*RedisClient) Delete ¶
func (r *RedisClient) Delete(key string) error
Delete method delete value based on the key provided
func (*RedisClient) Get ¶
func (r *RedisClient) Get(key string) (interface{}, error)
Get return value based on the key provided
func (*RedisClient) GetCapacity ¶
func (r *RedisClient) GetCapacity() (interface{}, error)
GetCapacity method return redis database size
func (*RedisClient) GetNumberOfRecords ¶
func (r *RedisClient) GetNumberOfRecords() int
GetNumberOfRecords return number of records
func (*RedisClient) Middleware ¶
func (r *RedisClient) Middleware(hash hash.IHash) echo.MiddlewareFunc
Middleware for echo framework
type SQLLikeClient ¶
SQLLikeClient manage all SQL-Like actions
func NewSQLLike ¶
func NewSQLLike(config *LIKE) *SQLLikeClient
NewSQLLike init new instance The sql package must be used in conjunction with a database driver. See https://golang.org/s/sqldrivers for a list of driverNames.
func (*SQLLikeClient) Execute ¶
func (c *SQLLikeClient) Execute( query string, dataModel interface{}) (interface{}, error)
Execute return results based on 'query' and 'dataModel'
type Set ¶
type Set struct { Operator UpdateOperators `json:"operator"` Data interface{} `json:"data"` }
Set mongo model
type UpdateOperators ¶
type UpdateOperators string
UpdateOperators mongodb update operation type
const (
Replaces UpdateOperators = "$set"
)
This is for mongodb update operation constant