Documentation ¶
Overview ¶
Package db implements a wrapper over the go-redis/redis.
There may be an attempt to mimic sonic-py-swsssdk to ease porting of code written in python using that SDK to Go Language.
Example:
Initialization:
d, _ := db.NewDB(db.Options { DBNo : db.ConfigDB, InitIndicator : "CONFIG_DB_INITIALIZED", TableNameSeparator: "|", KeySeparator : "|", })
Close:
d.DeleteDB()
No-Transaction SetEntry
tsa := db.TableSpec { Name: "ACL_TABLE" } tsr := db.TableSpec { Name: "ACL_RULE" }
ca := make([]string, 1, 1)
ca[0] = "MyACL1_ACL_IPV4" akey := db.Key { Comp: ca} avalue := db.Value {map[string]string {"ports":"eth0","type":"mirror" }}
d.SetEntry(&tsa, akey, avalue)
GetEntry
avalue, _ := d.GetEntry(&tsa, akey)
GetKeys
keys, _ := d.GetKeys(&tsa);
GetKeysPattern
keys, _ := d.GetKeys(&tsa, akeyPattern);
No-Transaction DeleteEntry
d.DeleteEntry(&tsa, akey)
GetTable
ta, _ := d.GetTable(&tsa)
No-Transaction DeleteTable
d.DeleteTable(&ts)
Transaction
rkey := db.Key { Comp: []string { "MyACL2_ACL_IPV4", "RULE_1" }} rvalue := db.Value { Field: map[string]string { "priority" : "0", "packet_action" : "eth1", }, }
d.StartTx([]db.WatchKeys { {Ts: &tsr, Key: &rkey} }, []*db.TableSpec { &tsa, &tsr })
d.SetEntry( &tsa, akey, avalue) d.SetEntry( &tsr, rkey, rvalue)
e := d.CommitTx()
Transaction Abort
d.StartTx([]db.WatchKeys {}, []*db.TableSpec { &tsa, &tsr }) d.DeleteEntry( &tsa, rkey) d.AbortTx()
Package db implements a wrapper over the go-redis/redis.
Package db implements a wrapper over the go-redis/redis.
Index ¶
- Constants
- func ClearCache() error
- func ClearDBStats() error
- func ConfigDBClearLock() error
- func ConfigDBTryLock(token string) error
- func ConfigDBUnlock(token string) error
- func GetDBStatsTotals() (uint, time.Duration, time.Duration)
- func HandleSIGUSR2()
- func NewValidationSession() (*cvl.CVL, error)
- func ReconfigureCache() error
- func ReconfigureStats() error
- func SignalHandler()
- type CommitIdDbDs
- type DB
- func (d *DB) AbortSessTx() error
- func (d *DB) AbortTx() error
- func (d *DB) AppendWatchTx(w []WatchKeys, tss []*TableSpec) error
- func (d *DB) ClosePubSubRpcDB() error
- func (d *DB) CommitSessTx() error
- func (d *DB) CommitTx() error
- func (d *DB) CreateEntry(ts *TableSpec, key Key, value Value) error
- func (d *DB) DeclareSP() error
- func (d *DB) DeleteDB() error
- func (d *DB) DeleteEntry(ts *TableSpec, key Key) error
- func (d *DB) DeleteEntryFields(ts *TableSpec, key Key, value Value) error
- func (d *DB) DeleteKeys(ts *TableSpec, key Key) error
- func (d *DB) DeleteMapAll(ts *TableSpec) error
- func (d *DB) DeleteTable(ts *TableSpec) error
- func (d *DB) ExistKeysPattern(ts *TableSpec, pat Key) (bool, error)
- func (d *DB) Export(filePath string) (outFile string, err error)
- func (d *DB) ExportRaw(filePath string) (outFile string, err error)
- func (d *DB) Get(key string) (string, error)
- func (d *DB) GetConfig(tables []*TableSpec, opt *GetConfigOptions) (map[TableSpec]Table, error)
- func (d *DB) GetDebugCvlECD() interface{}
- func (d *DB) GetDebugDB() interface{}
- func (d *DB) GetDebugTxCmds() interface{}
- func (d *DB) GetEntries(ts *TableSpec, keys []Key) ([]Value, []error)
- func (d *DB) GetEntry(ts *TableSpec, key Key) (Value, error)
- func (d *DB) GetKeys(ts *TableSpec) ([]Key, error)
- func (d *DB) GetKeysByPattern(ts *TableSpec, pattern string) ([]Key, error)
- func (d *DB) GetKeysPattern(ts *TableSpec, pat Key) ([]Key, error)
- func (d *DB) GetMAP(ts *TableSpec) (MAP, error)
- func (d *DB) GetMap(ts *TableSpec, mapKey string) (string, error)
- func (d *DB) GetMapAll(ts *TableSpec) (Value, error)
- func (d *DB) GetRpcResponse(numResponses int, timeout int) ([]string, error)
- func (d *DB) GetStats() *DBStats
- func (d *DB) GetTable(ts *TableSpec) (Table, error)
- func (d *DB) GetTablePattern(ts *TableSpec, pat Key) (Table, error)
- func (d *DB) HasSP() bool
- func (d *DB) IsDirtified() bool
- func (d *DB) IsOpen() bool
- func (d *DB) ModEntry(ts *TableSpec, key Key, value Value) error
- func (d *DB) Name() string
- func (d *DB) NewScanCursor(ts *TableSpec, pattern Key, scOpts *ScanCursorOpts) (*ScanCursor, error)
- func (d *DB) NewValidationSession() (*cvl.CVL, error)
- func (d *DB) OnChangeCacheDelete(ts *TableSpec, key Key) (Value, error)
- func (d *DB) OnChangeCacheUpdate(ts *TableSpec, key Key) (Value, Value, error)
- func (d *DB) Publish(channel string, message interface{}) error
- func (d *DB) RegisterTableForOnChangeCaching(ts *TableSpec) error
- func (d *DB) ReleaseSP() error
- func (d *DB) Rollback2SP() error
- func (d *DB) RunScript(script *redis.Script, keys []string, args ...interface{}) *redis.Cmd
- func (d *DB) SendRpcRequest(requestChannel string, message string) (int, error)
- func (d *DB) SetEntry(ts *TableSpec, key Key, value Value) error
- func (d *DB) SetMap(ts *TableSpec, mapKey string, mapValue string) error
- func (d *DB) StartSessTx(w []WatchKeys, tss []*TableSpec) error
- func (d *DB) StartTx(w []WatchKeys, tss []*TableSpec) error
- func (d *DB) StoreCVLHint(key string, value interface{}) error
- func (d DB) String() string
- func (d *DB) UnsubscribeDB() error
- type DBCacheConfig
- type DBDatastore
- type DBGlobalCache
- type DBGlobalStats
- type DBNum
- type DBStats
- type DBStatsConfig
- type DefaultDbDs
- type GetConfigOptions
- type HFunc
- type HFuncSA
- type Key
- type LockStruct
- type MAP
- type Options
- type SEvent
- type SKey
- type ScanCursor
- type ScanCursorOpts
- type ScanType
- type SessNotif
- type Stats
- type Table
- type TableSpec
- type Value
- func (v Value) Compare4TxOps(dst Value) (isHSet, isHDel bool)
- func (v *Value) ContainsAll(other *Value) bool
- func (v Value) Copy() (rV Value)
- func (v *Value) Equals(other *Value) bool
- func (v *Value) Get(name string) string
- func (v *Value) GetInt(name string) (int, error)
- func (v *Value) GetList(name string) []string
- func (v *Value) Has(name string) bool
- func (v *Value) IsPopulated() bool
- func (v *Value) Remove(name string)
- func (v *Value) Set(name, value string)
- func (v *Value) SetInt(name string, value int)
- func (v *Value) SetList(name string, items []string)
- func (v Value) String() string
- type WatchKeys
Constants ¶
const ( DefaultRedisUNIXSocket string = "/var/run/redis/redis.sock" DefaultRedisLocalTCPEP string = "localhost:6379" DefaultRedisRemoteTCPEP string = "127.0.0.1:6379" DefaultRedisUNIXNetwork string = "unix" DefaultRedisTCPNetwork string = "tcp" )
const ( InitialTxPipelineSize int = 100 InitialTablesCount int = 20 InitialTableEntryCount int = 50 InitialTablePatternCount int = 5 InitialMapsCount int = 10 InitialMapKeyCount int = 50 )
const ( ConnectionClosed = tlerr.TranslibDBInvalidState("connection closed") OnChangeDisabled = tlerr.TranslibDBInvalidState("OnChange disabled") SupportsReadOnly = tlerr.TranslibDBInvalidState("Supported on read only") OnChangeNoSupport = tlerr.TranslibDBInvalidState("OnChange not supported") SupportsCfgDBOnly = tlerr.TranslibDBInvalidState("Supported on CfgDB only") UseGetEntry = tlerr.TranslibDBInvalidState("Use GetEntry()") )
const ( InitTable2sDBSize int = 20 InitSDBArraySize int = 5 )
const (
InitialDebugDBSize int = 20
)
Variables ¶
This section is empty.
Functions ¶
func ClearCache ¶
func ClearCache() error
func ClearDBStats ¶
func ClearDBStats() error
func ConfigDBClearLock ¶
func ConfigDBClearLock() error
func ConfigDBTryLock ¶
func ConfigDBUnlock ¶
func HandleSIGUSR2 ¶
func HandleSIGUSR2()
func NewValidationSession ¶
func ReconfigureCache ¶
func ReconfigureCache() error
func ReconfigureStats ¶
func ReconfigureStats() error
func SignalHandler ¶
func SignalHandler()
Types ¶
type CommitIdDbDs ¶
type CommitIdDbDs struct {
CommitID string
}
CommitIdDbDs is a Datastore modeled from a saved-to-disk CONFIG_DB of a commit-id which is stored in the CHECKPOINTS_DIR, with a CHECKPOINT_EXT (cp.json)
func (*CommitIdDbDs) Attributes ¶
func (ds *CommitIdDbDs) Attributes() map[string]string
type DB ¶
type DB struct { Opts *Options // contains filtered or unexported fields }
DB is the main type.
func SubscribeDB ¶
SubscribeDB is the factory method to create a subscription to the DB. The returned instance can only be used for Subscription.
func SubscribeDBSA ¶
SubscribeDBSA is Session Aware factory method to create a subscription to DB The returned instance can only be used for Subscription.
func (*DB) AbortSessTx ¶
func (*DB) ClosePubSubRpcDB ¶
func (*DB) CommitSessTx ¶
func (*DB) CreateEntry ¶
CreateEntry creates an entry(row) in the table.
func (*DB) DeleteEntry ¶
DeleteEntry deletes an entry(row) in the table.
func (*DB) DeleteEntryFields ¶
DeleteEntryFields deletes some fields/columns in an entry(row) in the table.
func (*DB) DeleteKeys ¶
DeleteKeys deletes all entry/row keys matching a pattern.
func (*DB) DeleteMapAll ¶
DeleteMapAll - There is no transaction support on these. TBD: Unexport this. : Lower case it, and reference too
func (*DB) DeleteTable ¶
DeleteTable deletes the entire table.
func (*DB) ExistKeysPattern ¶
ExistKeysPattern checks if a key pattern exists in a table Note:
- Statistics do not capture when the CAS Tx Cache results in a quicker response. This is to avoid mis-interpreting per-connection statistics.
func (*DB) Export ¶
Export writes the full DB contents to a file in sonic db json format. Includes contents from transaction cache, if present. Uses the sonic-cfggen tool to remove system default entries/keys and apply standard format.
If filePath is empty or has '*', it will be expanded to a random name similar to the os.CreateTemp() API. Actual file path will be returned to the caller (outFile). Contents will be written and formatted in multiple steps. Hence outFile may a valid path (but with garbage contents) even if there was an error. Caller must disregard its contents and cleanup the file when outFile != "" && err != nil.
func (*DB) ExportRaw ¶
ExportRaw is similar to Export(), but does not process the output using sonic-cfggen tool.
func (*DB) GetConfig ¶
GetConfig API to get some tables. Very expensive operation (time/resources) If len(tables) == 0, return all tables in the CONFIG_DB Notes:
- Only supported on the CONFIG_DB
- The keys of the table should not contain TableSeparator, or KeySeparator (CONFIG_DB table keys should not contain "|" (defaults for TableSeparator, or KeySeparator))
- Only supported when write/set is disabled [IsWriteDisabled == true ]
- OnChange not supported [IsEnableOnChange == false]
- PCC (per_connection_cache) is not supported, and it will log an error/ warning.
func (*DB) GetDebugCvlECD ¶
func (d *DB) GetDebugCvlECD() interface{}
func (*DB) GetDebugDB ¶
func (d *DB) GetDebugDB() interface{}
func (*DB) GetDebugTxCmds ¶
func (d *DB) GetDebugTxCmds() interface{}
func (*DB) GetEntries ¶
GetEntries retrieves the entries from the table for the given keys using redis pipelining, if the key is not present in the cache. returns slice of value and error; Note: error slice will be nil, if there is no error occurred for any of the given keys.
func (*DB) GetKeysByPattern ¶
GetKeysByPattern retrieves all entry/row keys matching with the given pattern Deprecated: use GetKeysPattern()
func (*DB) GetRpcResponse ¶
func (*DB) GetStats ¶
GetStats primarily returns CAS Transaction Cmds list length in AllTables The TxCmdsLen is always in the ret.AllTables.TxCmdsLen
func (*DB) GetTablePattern ¶
GetTablePattern is similar to GetTable, except, it gets a subset of the table restricted by the key pattern "pat". It is expected that there will be a single call to the underlying go-redis layer, perhaps through the use of a script. However, the caller is not advised to rely on this, and encouraged to use this instead of the current GetTable() for reasonably sized subsets of tables ("reasonably sized" to be determined by experiments) to obtain a more performant behavior. Note: The time/hit statistics do not cover the error cases.
func (*DB) IsDirtified ¶
func (*DB) NewScanCursor ¶
func (d *DB) NewScanCursor(ts *TableSpec, pattern Key, scOpts *ScanCursorOpts) (*ScanCursor, error)
NewScanCursor Factory method to create ScanCursor; Scan cursor will not be supported for write enabled DB.
func (*DB) OnChangeCacheDelete ¶
OnChangeCacheDelete deletes an entry from the on_change cache. Returns the previously cached Value object; or an empty Value if there was no such cache entry.
func (*DB) OnChangeCacheUpdate ¶
OnChangeCacheUpdate reads a db entry from redis and updates the on_change cache. Returns both previously cached Value and current Value. Previous Value will be empty if there was no such cache entry earlier. Returns an error if DB entry does not exists or could not be read.
func (*DB) RegisterTableForOnChangeCaching ¶
func (*DB) Rollback2SP ¶
func (*DB) SendRpcRequest ¶
func (*DB) StartSessTx ¶
StartSessTx CommitSessTx AbortSessTx Originally (roughly 4.0.x and before) we have StartTx(), CommitTx(), and AbortTx() which represented the API for invoking redis CAS (Check-And-Set) Transactions. With the attempt at Config Sessions a.k.a. Two-Phase Commit, these APIs may have to be re-arranged, because a few of the Action Callback handlers in the transformer invoke these API directly. Ideally all db.[Start|Commit|Abort]Tx need to be rewritten to cs.[Start|Commit|Abort]Tx. But, that would mean changing App code.
func (*DB) StoreCVLHint ¶
StoreCVLHint Stores a key, value hint for CVL Session Custom Validation CBs
func (*DB) UnsubscribeDB ¶
UnsubscribeDB is used to close a DB subscription
type DBCacheConfig ¶
type DBCacheConfig struct { PerConnection bool // Enable per DB conn cache Global bool // Enable global cache (TBD) CacheTables map[string]bool // Only cache these tables. // Empty == Cache all tables NoCacheTables map[string]bool // Do not cache these tables. // "all" == Do not cache any tables CacheMaps map[string]bool // Only cache these maps. // Empty == Cache all maps NoCacheMaps map[string]bool // Do not cache these maps }
type DBDatastore ¶
type DBGlobalCache ¶
type DBGlobalCache struct {
Databases [MaxDB]dbCache
}
type DBGlobalStats ¶
type DBGlobalStats struct { New uint `json:"new-db"` Delete uint `json:"delete-db"` PeakOpen uint `json:"peak-open"` NewTime time.Duration `json:"new-time,omitempty"` NewPeak time.Duration `json:"peak-new-time,omitempty"` ZeroGetHits uint `json:"zero-get-ops-db"` Databases []DBStats `json:"dbs,omitempty"` }
func GetDBStats ¶
func GetDBStats() (*DBGlobalStats, error)
type DBNum ¶
type DBNum int
DBNum type indicates the type of DB (Eg: ConfigDB, ApplDB, ...).
func GetdbNameToIndex ¶
type DBStats ¶
type DBStatsConfig ¶
type DefaultDbDs ¶
type DefaultDbDs struct { }
DefaultDbDs is the default Datastore representing the data stored in the CONFIG_DB database(/selection) of the redis-server
func (*DefaultDbDs) Attributes ¶
func (ds *DefaultDbDs) Attributes() map[string]string
type GetConfigOptions ¶
type Key ¶
type Key struct {
Comp []string
}
Key is the db key components without table name prefix. (Eg: { Comp : [] string { "acl1", "rule1" } } ).
func (*Key) IsAllKeyPattern ¶
IsAllKeyPattern returns true if it is an all key wildcard pattern. (i.e. A key with a single component "*")
func (Key) IsPattern ¶
IsPattern checks if the key has redis glob-style pattern. Supports only '*' and '?' wildcards.
type LockStruct ¶
type Options ¶
type Options struct { DBNo DBNum InitIndicator string TableNameSeparator string //Overriden by the DB config file's separator. KeySeparator string //Overriden by the DB config file's separator. IsWriteDisabled bool //Is write/set mode disabled ? IsCacheEnabled bool //Is cache (Per Connection) allowed? // OnChange caching for the DBs passed from Translib's Subscribe Infra // to the Apps. SDB is the SubscribeDB() returned handle on which // notifications of change are received. IsOnChangeEnabled bool // whether OnChange cache enabled SDB *DB //The subscribeDB handle (Future Use) IsSubscribeDB bool // Opened by SubscribeDB(Sess)? IsSession bool // Is this a Candidate Config DB ? ConfigDBLazyLock bool // For Non-CCDB Action()/RPC (may write to ConfigDB) TxCmdsLim int // Tx Limit for Candidate Config DB IsReplaced bool // Is candidate Config DB updated by config-replace operation. IsCommitted bool // Is candidate Config DB committed. // Alternate Datastore: By default, we query redis CONFIG_DB. // Front-end an alternate source of data. (Eg: config_db.cp.json // from a saved commit-id, or snapshot) Datastore DBDatastore DisableCVLCheck bool }
Options gives parameters for opening the redis client.
type SEvent ¶
type SEvent int
const ( SEventNone SEvent = iota // No Op SEventHSet // HSET, HMSET, and its variants SEventHDel // HDEL, also SEventDel generated, if HASH is becomes empty SEventDel // DEL, & also if key gets deleted (empty HASH, expire,..) SEventOther // Some other command not covered above. // The below two are always sent regardless of SEMap. SEventClose // Close requested due to Unsubscribe() called. SEventErr // Error condition. Call Unsubscribe, after return. )
type SKey ¶
type SKey struct { Ts *TableSpec Key *Key SEMap map[SEvent]bool // nil map indicates subscribe to all Opaque interface{} // opaque data set by the caller }
SKey is (TableSpec, Key, []SEvent) 3-tuples to be watched in a Transaction.
type ScanCursor ¶
type ScanCursor struct {
// contains filtered or unexported fields
}
func (*ScanCursor) DeleteScanCursor ¶
func (sc *ScanCursor) DeleteScanCursor() error
DeleteScanCursor Gently release state/cache of ScanCursor
func (*ScanCursor) GetNextFields ¶
func (sc *ScanCursor) GetNextFields(scOpts *ScanCursorOpts) (Value, bool, error)
GetNextFields retrieves a few matching fields. bool returns true if the scan is complete.
func (*ScanCursor) GetNextKeys ¶
func (sc *ScanCursor) GetNextKeys(scOpts *ScanCursorOpts) ([]Key, bool, error)
GetNextKeys retrieves a few keys. bool returns true if the scan is complete.
func (*ScanCursor) GetNextRedisKeys ¶
func (sc *ScanCursor) GetNextRedisKeys(scOpts *ScanCursorOpts) ([]string, bool, error)
GetNextRedisKeys retrieves a few redisKeys. bool returns true if the scan is complete
type ScanCursorOpts ¶
type ScanCursorOpts struct { CountHint int64 // Hint of redis work required ReturnFixed bool // (TBD) Return exactly CountHint # of keys AllowDuplicates bool // Do not suppress redis duplicate keys ScanType // To mention the type of scan; default is KeyScanType FldScanPatt string // Field pattern to scan AllowWritable bool // Allow on write enabled DB object; ignores tx cache }
type ScanType ¶
type ScanType int
ScanType type indicates the type of scan (Eg: KeyScanType, FieldScanType).
type Stats ¶
type Stats struct { Hits uint `json:"hits,omitempty"` Time time.Duration `json:"total-time,omitempty"` Peak time.Duration `json:"peak-time,omitempty"` GetEntryHits uint `json:"get-entry-hits,omitempty"` GetKeysHits uint `json:"get-keys-hits,omitempty"` GetKeysPatternHits uint `json:"get-keys-pattern-hits,omitempty"` GetMapHits uint `json:"get-map-hits,omitempty"` GetMapAllHits uint `json:"get-map-all-hits,omitempty"` GetEntriesHits uint `json:"get-entries-hits,omitempty"` GetTablePatternHits uint `json:"get-table-pattern-hits,omitempty"` ExistsKeyPatternHits uint `json:"exists-key-pattern-hits,omitempty"` NewScanCursorHits uint `json:"new-scan-cursor-hits,omitempty"` DeleteScanCursorHits uint `json:"delete-scan-cursor-hits,omitempty"` GetNextKeysHits uint `json:"get-next-keys-hits,omitempty"` GetEntryCacheHits uint `json:"get-entry-cache-hits,omitempty"` GetKeysCacheHits uint `json:"keys-cache-hits,omitempty"` GetKeysPatternCacheHits uint `json:"keys-pattern-cache-hits,omitempty"` GetMapCacheHits uint `json:"get-map-cache-hits,omitempty"` GetMapAllCacheHits uint `json:"get-map-all-cache-hits,omitempty"` GetTablePatternCacheHits uint `json:"get-table-pattern-cache-hits,omitempty"` ExistsKeyPatternCacheHits uint `json:"exists-key-pattern-cache-hits,omitempty"` GetEntryTime time.Duration `json:"get-entry-time,omitempty"` GetKeysTime time.Duration `json:"get-keys-time,omitempty"` GetKeysPatternTime time.Duration `json:"get-keys-pattern-time,omitempty"` GetMapTime time.Duration `json:"get-map-time,omitempty"` GetMapAllTime time.Duration `json:"get-map-all-time,omitempty"` GetNextKeysTime time.Duration `json:"get-next-keys-time,omitempty"` GetEntriesTime time.Duration `json:"get-entries-time,omitempty"` GetTablePatternTime time.Duration `json:"get-table-pattern-time,omitempty"` ExistsKeyPatternTime time.Duration `json:"exists-key-pattern-time,omitempty"` GetEntryPeak time.Duration `json:"get-entry-peak-time,omitempty"` GetKeysPeak time.Duration `json:"get-keys-peak-time,omitempty"` GetKeysPatternPeak time.Duration `json:"get-keys-pattern-peak-time,omitempty"` GetMapPeak time.Duration `json:"get-map-peak-time,omitempty"` GetMapAllPeak time.Duration `json:"get-map-all-peak-time,omitempty"` GetNextKeysPeak time.Duration `json:"get-next-keys-peak-time,omitempty"` GetEntriesPeak time.Duration `json:"get-entries-peak-time,omitempty"` GetTablePatternPeak time.Duration `json:"get-table-pattern-peak-time,omitempty"` ExistsKeyPatternPeak time.Duration `json:"exists-key-pattern-peak-time,omitempty"` // CAS Transaction Cmds Stats: Currently Only Used by GetStats() for // the Candidate Configuration (CC) DB // Running Totals (i.e. over several DB connections) are not maintained // reliably. TxCmdsLen uint `json:"tx-cmds-len"` }
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
type TableSpec ¶
type TableSpec struct { Name string // https://github.com/project-arlo/sonic-mgmt-framework/issues/29 // CompCt tells how many components in the key. Only the last component // can have TableSeparator as part of the key. Otherwise, we cannot // tell where the key component begins. CompCt int // NoDelete flag (if it is set to true) is to skip the row entry deletion from // the table when the "SetEntry" or "ModEntry" method is called with empty Value Field map. NoDelete bool }
TableSpec gives the name of the table, and other per-table customizations. (Eg: { Name: ACL_TABLE" }).
func Tables2TableSpecs ¶
Tables2TableSpecs - Convenience function to make TableSpecs from strings. This only works on Tables having key components without TableSeparator as part of the key.
type Value ¶
Value gives the fields as a map. (Eg: { Field: map[string]string { "type" : "l3v6", "ports" : "eth0" } } ).
func (Value) Compare4TxOps ¶
Compare4TxOps gives the Redis Ops/Notifs that are to be generated whilst going from a v Value to dst Value. Returns if HSet, and/or HDel needs to be performed
func (*Value) ContainsAll ¶
ContainsAll returns true if this value is a superset of the other value.
func (*Value) Equals ¶
Equals returns true if this value contains same set of attributes as the other value
func (*Value) Get ¶
Get returns the value of a field. Returns empty string if the field does not exists. Use Has() function to check existance of field.
func (*Value) GetInt ¶
GetInt returns value of a field as int. Returns 0 if the field does not exists. Returns an error if the field value is not a number.
func (*Value) GetList ¶
GetList returns the value of a an array field. A "@" suffix is automatically appended to the field name if not present (as per swsssdk convention). Field value is split by comma and resulting slice is returned. Empty slice is returned if field not exists.
func (*Value) IsPopulated ¶
Source Files ¶
- cvl_db_access.go
- db.go
- db_cache.go
- db_config.go
- db_cursor.go
- db_cvl_hint.go
- db_datastore.go
- db_debug.go
- db_export.go
- db_get.go
- db_get_config.go
- db_key.go
- db_keys_pattern.go
- db_lock.go
- db_map.go
- db_onchangecache.go
- db_redis_opts.go
- db_rpcdb.go
- db_savepoint.go
- db_session.go
- db_signal.go
- db_stats.go
- db_subscribe_sa.go
- db_table.go
- db_table_pattern.go
- db_value.go
- map.go
- subscribe.go