Created
August 28, 2019 20:02
-
-
Save rusenask/93df8a9b2faccd8cf087bc33fa78bccd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (m *BinManager) BinPut(ctx context.Context, b *bin.Bin) (err error) { | |
b.Requests = nil | |
encoded, err := proto.Marshal(b) | |
if err != nil { | |
return err | |
} | |
return m.storage.Store(ctx, "bins/"+b.Id, encoded, nil) | |
} | |
... | |
// store package | |
func (s *Storage) Store(ctx context.Context, id string, data []byte, metadata map[string]string) error { | |
err := s.db.Update(func(txn *badger.Txn) error { | |
// Your code here… | |
return txn.Set([]byte(id), data) | |
}) | |
return err | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment