From 5b526a73bd9558ffe9fbebc9623028ae00fcf8cf Mon Sep 17 00:00:00 2001 From: Cem KIY Date: Sat, 13 Apr 2019 17:39:33 +0300 Subject: [PATCH] fixed #402 item get value error fix (#404) - bager rename badger - Value method not usable, therfore changed to ValueCopy --- storage/badger/badger.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/storage/badger/badger.go b/storage/badger/badger.go index 2b6e03a..4792cc9 100644 --- a/storage/badger/badger.go +++ b/storage/badger/badger.go @@ -29,7 +29,7 @@ type Storage struct { // Init client storage. func (s *Storage) Init() error { - s.name = "bager" + s.name = "badger" s.opts = badger.DefaultOptions s.opts.Dir = os.TempDir() + "badger" s.opts.ValueDir = os.TempDir() + "badger" @@ -70,7 +70,7 @@ func (s *Storage) setBadger(key string, count int64) { } } -func (s *Storage) getBager(key string, count *int64) { +func (s *Storage) getBadger(key string, count *int64) { db, err := badger.Open(s.opts) if err != nil { @@ -90,7 +90,8 @@ func (s *Storage) getBager(key string, count *int64) { if err != nil { return err } - val, err := item.Value() + dst := []byte{} + val, err := item.ValueCopy(dst) if err != nil { return err } @@ -143,7 +144,7 @@ func (s *Storage) AddAndroidError(count int64) { // GetTotalCount show counts of all notification. func (s *Storage) GetTotalCount() int64 { var count int64 - s.getBager(storage.TotalCountKey, &count) + s.getBadger(storage.TotalCountKey, &count) return count } @@ -151,7 +152,7 @@ func (s *Storage) GetTotalCount() int64 { // GetIosSuccess show success counts of iOS notification. func (s *Storage) GetIosSuccess() int64 { var count int64 - s.getBager(storage.IosSuccessKey, &count) + s.getBadger(storage.IosSuccessKey, &count) return count } @@ -159,7 +160,7 @@ func (s *Storage) GetIosSuccess() int64 { // GetIosError show error counts of iOS notification. func (s *Storage) GetIosError() int64 { var count int64 - s.getBager(storage.IosErrorKey, &count) + s.getBadger(storage.IosErrorKey, &count) return count } @@ -167,7 +168,7 @@ func (s *Storage) GetIosError() int64 { // GetAndroidSuccess show success counts of Android notification. func (s *Storage) GetAndroidSuccess() int64 { var count int64 - s.getBager(storage.AndroidSuccessKey, &count) + s.getBadger(storage.AndroidSuccessKey, &count) return count } @@ -175,7 +176,7 @@ func (s *Storage) GetAndroidSuccess() int64 { // GetAndroidError show error counts of Android notification. func (s *Storage) GetAndroidError() int64 { var count int64 - s.getBager(storage.AndroidErrorKey, &count) + s.getBadger(storage.AndroidErrorKey, &count) return count }