summary refs log tree commit diff stats
path: root/cache.go
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-06-04 16:13:27 -0400
committerBen Morrison <ben@gbmor.dev>2019-06-04 18:20:09 -0400
commit887c25ef0188d8a2ccd811c1d5896d7d71f254df (patch)
treecacc7ca191b30acd91bc66a96fcadc6bb57ff0ee /cache.go
parentb9a7d0d268e7b4c782f1ad1387f36c1ab0bdf5d0 (diff)
downloadgetwtxt-887c25ef0188d8a2ccd811c1d5896d7d71f254df.tar.gz
expanding options for databases. abstractions for database push/pull functions
Diffstat (limited to 'cache.go')
-rw-r--r--cache.go33
1 files changed, 25 insertions, 8 deletions
diff --git a/cache.go b/cache.go
index 3a7886e..fb32e04 100644
--- a/cache.go
+++ b/cache.go
@@ -75,12 +75,7 @@ func refreshCache() {
 	confObj.Mu.Unlock()
 }
 
-// Pushes the registry's cache data to a local
-// database for safe keeping.
-func pushDatabase() error {
-	db := <-dbChan
-	dbChan <- db
-
+func (lvl dbLevel) push() error {
 	twtxtCache.Mu.RLock()
 	var dbBasket = &leveldb.Batch{}
 	for k, v := range twtxtCache.Users {
@@ -101,7 +96,7 @@ func pushDatabase() error {
 	}
 	remoteRegistries.Mu.RUnlock()
 
-	if err := db.Write(dbBasket, nil); err != nil {
+	if err := lvl.db.Write(dbBasket, nil); err != nil {
 		return err
 	}
 
@@ -112,11 +107,33 @@ func pushDatabase() error {
 	return nil
 }
 
+func (lite dbSqlite) push() error {
+
+	return nil
+}
+
+func (lite dbSqlite) pull() {
+
+}
+
+// Pushes the registry's cache data to a local
+// database for safe keeping.
+func pushDatabase() error {
+	db := <-dbChan
+	dbChan <- db
+
+	return db.push()
+}
+
 func pullDatabase() {
 	db := <-dbChan
 	dbChan <- db
+	db.pull()
+}
+
+func (lvl dbLevel) pull() {
 
-	iter := db.NewIterator(nil, nil)
+	iter := lvl.db.NewIterator(nil, nil)
 
 	for iter.Next() {
 		key := string(iter.Key())