From e4246138cb9ffb819c052ba17a9fbdf915427291 Mon Sep 17 00:00:00 2001 From: "Santiago M. Mola" Date: Mon, 29 Aug 2016 22:47:13 +0200 Subject: storage: Add object type hint parameter to ObjectStorage.Get. (#69) Some storage backends can optimize object lookup if they get the object type that is expected. So we the signature of the Get method is now Get(Hash, ObjectType). Added generic tests for storage backends. --- examples/object_storage/storage.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'examples') diff --git a/examples/object_storage/storage.go b/examples/object_storage/storage.go index c119adc..0513654 100644 --- a/examples/object_storage/storage.go +++ b/examples/object_storage/storage.go @@ -86,8 +86,8 @@ func (o *AerospikeObjectStorage) Set(obj core.Object) (core.Hash, error) { return obj.Hash(), err } -func (o *AerospikeObjectStorage) Get(h core.Hash) (core.Object, error) { - key, err := keyFromObject(h) +func (o *AerospikeObjectStorage) Get(h core.Hash, t core.ObjectType) (core.Object, error) { + key, err := keyFromObject(h, t) if err != nil { return nil, err } @@ -113,8 +113,8 @@ func (o *AerospikeObjectStorage) Iter(t core.ObjectType) (core.ObjectIter, error return &AerospikeObjectIter{t, rs.Records}, nil } -func keyFromObject(h core.Hash) (*aerospike.Key, error) { - return aerospike.NewKey("test", "objects", h.String()) +func keyFromObject(h core.Hash, t core.ObjectType) (*aerospike.Key, error) { + return aerospike.NewKey("test", t.String(), h.String()) } type AerospikeObjectIter struct { -- cgit