Rename store Namespace / Prefix options to Database and Table (#1492)
* Rename Namespace to DB, Rename Prefix to table, Remove Suffix Option * Rename options * Rename options * Add store_table option * Table per service, not Database per service
This commit is contained in:
@@ -83,14 +83,11 @@ func (m *memoryStore) Read(key string, opts ...store.ReadOption) ([]*store.Recor
|
||||
}
|
||||
|
||||
func (m *memoryStore) get(k string) (*store.Record, error) {
|
||||
if len(m.options.Suffix) > 0 {
|
||||
k = k + m.options.Suffix
|
||||
if len(m.options.Table) > 0 {
|
||||
k = m.options.Table + "/" + k
|
||||
}
|
||||
if len(m.options.Prefix) > 0 {
|
||||
k = m.options.Prefix + "/" + k
|
||||
}
|
||||
if len(m.options.Namespace) > 0 {
|
||||
k = m.options.Namespace + "/" + k
|
||||
if len(m.options.Database) > 0 {
|
||||
k = m.options.Database + "/" + k
|
||||
}
|
||||
var storedRecord *internalRecord
|
||||
r, found := m.store.Get(k)
|
||||
@@ -142,14 +139,11 @@ func (m *memoryStore) Write(r *store.Record, opts ...store.WriteOption) error {
|
||||
|
||||
func (m *memoryStore) set(r *store.Record) {
|
||||
key := r.Key
|
||||
if len(m.options.Suffix) > 0 {
|
||||
key = key + m.options.Suffix
|
||||
if len(m.options.Table) > 0 {
|
||||
key = m.options.Table + "/" + key
|
||||
}
|
||||
if len(m.options.Prefix) > 0 {
|
||||
key = m.options.Prefix + "/" + key
|
||||
}
|
||||
if len(m.options.Namespace) > 0 {
|
||||
key = m.options.Namespace + "/" + key
|
||||
if len(m.options.Database) > 0 {
|
||||
key = m.options.Database + "/" + key
|
||||
}
|
||||
|
||||
// copy the incoming record and then
|
||||
@@ -175,14 +169,11 @@ func (m *memoryStore) Delete(key string, opts ...store.DeleteOption) error {
|
||||
}
|
||||
|
||||
func (m *memoryStore) delete(key string) {
|
||||
if len(m.options.Suffix) > 0 {
|
||||
key = key + m.options.Suffix
|
||||
if len(m.options.Table) > 0 {
|
||||
key = m.options.Table + "/" + key
|
||||
}
|
||||
if len(m.options.Prefix) > 0 {
|
||||
key = m.options.Prefix + "/" + key
|
||||
}
|
||||
if len(m.options.Namespace) > 0 {
|
||||
key = m.options.Namespace + "/" + key
|
||||
if len(m.options.Database) > 0 {
|
||||
key = m.options.Database + "/" + key
|
||||
}
|
||||
m.store.Delete(key)
|
||||
}
|
||||
@@ -226,14 +217,11 @@ func (m *memoryStore) list(limit, offset uint) []string {
|
||||
allKeys := make([]string, len(allItems))
|
||||
i := 0
|
||||
for k := range allItems {
|
||||
if len(m.options.Suffix) > 0 {
|
||||
k = strings.TrimSuffix(k, m.options.Suffix)
|
||||
if len(m.options.Database) > 0 {
|
||||
k = strings.TrimPrefix(k, m.options.Database+"/")
|
||||
}
|
||||
if len(m.options.Namespace) > 0 {
|
||||
k = strings.TrimPrefix(k, m.options.Namespace+"/")
|
||||
}
|
||||
if len(m.options.Prefix) > 0 {
|
||||
k = strings.TrimPrefix(k, m.options.Prefix+"/")
|
||||
if len(m.options.Table) > 0 {
|
||||
k = strings.TrimPrefix(k, m.options.Table+"/")
|
||||
}
|
||||
allKeys[i] = k
|
||||
i++
|
||||
|
||||
Reference in New Issue
Block a user