aboutsummaryrefslogtreecommitdiffstats
path: root/examples/storage/aerospike/storage.go
diff options
context:
space:
mode:
Diffstat (limited to 'examples/storage/aerospike/storage.go')
-rw-r--r--examples/storage/aerospike/storage.go38
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,