diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-12-15 13:45:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-15 13:45:52 +0100 |
commit | 249c4137f4f34992c9bb6a60954e30a27994add7 (patch) | |
tree | 1188a410d368c619548d74798c474e04469eabae /examples/storage | |
parent | f01fd176ff61a3f37d096939690aa103de054ecc (diff) | |
download | go-git-249c4137f4f34992c9bb6a60954e30a27994add7.tar.gz |
storage: shallow storage (#180)
* storage: shallow storage
* changes
* changes
Diffstat (limited to 'examples/storage')
-rw-r--r-- | examples/storage/aerospike/storage.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/examples/storage/aerospike/storage.go b/examples/storage/aerospike/storage.go index 87d4a29..3ce5f5b 100644 --- a/examples/storage/aerospike/storage.go +++ b/examples/storage/aerospike/storage.go @@ -248,6 +248,44 @@ func (s *Storage) buildConfigKey() (*driver.Key, error) { return driver.NewKey(s.ns, configSet, fmt.Sprintf("%s|config", s.url)) } +func (s *Storage) Shallow() ([]plumbing.Hash, error) { + key, err := s.buildShallowKey() + if err != nil { + return nil, err + } + + rec, err := s.client.Get(nil, key) + if err != nil { + return nil, err + } + + var h []plumbing.Hash + return h, json.Unmarshal(rec.Bins["blob"].([]byte), h) +} + +func (s *Storage) SetShallow(hash []plumbing.Hash) error { + key, err := s.buildShallowKey() + if err != nil { + return err + } + + json, err := json.Marshal(hash) + if err != nil { + return err + } + + bins := driver.BinMap{ + urlField: s.url, + "blob": json, + } + + return s.client.Put(nil, key, bins) +} + +func (s *Storage) buildShallowKey() (*driver.Key, error) { + return driver.NewKey(s.ns, configSet, fmt.Sprintf("%s|config", s.url)) +} + func createIndexes(c *driver.Client, ns string) error { for _, set := range [...]string{ referencesSet, |