Skip to content

Instantly share code, notes, and snippets.

@rusenask
Created August 28, 2019 20:02
Show Gist options
  • Save rusenask/93df8a9b2faccd8cf087bc33fa78bccd to your computer and use it in GitHub Desktop.
Save rusenask/93df8a9b2faccd8cf087bc33fa78bccd to your computer and use it in GitHub Desktop.
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