diff --git a/weed/filer/arangodb/arangodb_store.go b/weed/filer/arangodb/arangodb_store.go index a9f55f5bc..a39735108 100644 --- a/weed/filer/arangodb/arangodb_store.go +++ b/weed/filer/arangodb/arangodb_store.go @@ -33,6 +33,7 @@ type Model struct { Directory string `json:"directory,omitempty"` Name string `json:"name,omitempty"` Bucket string `json:"bucket,omitempty"` + Ttl string `json:"ttl,omitempty"` //arangodb does not support binary blobs //we encode byte slice into uint64 slice @@ -108,10 +109,15 @@ func (store *ArangodbStore) connection(uris []string, user string, pass string, }); err != nil { return err } + if _, _, err = store.collection.EnsurePersistentIndex(ctx, []string{"directory"}, &driver.EnsurePersistentIndexOptions{Name: "IDX_directory"}); err != nil { return err } + if _, _, err = store.collection.EnsureTTLIndex(ctx, "ttl", 1, + &driver.EnsureTTLIndexOptions{Name: "IDX_TTL"}); err != nil { + return err + } if _, _, err = store.collection.EnsurePersistentIndex(ctx, []string{"name"}, &driver.EnsurePersistentIndexOptions{ Name: "IDX_name", @@ -188,6 +194,11 @@ func (store *ArangodbStore) InsertEntry(ctx context.Context, entry *filer.Entry) Meta: bytesToArray(meta), Bucket: bucket, } + if entry.TtlSec > 0 { + model.Ttl = time.Now().Add(time.Second * time.Duration(entry.TtlSec)).Format(time.RFC3339) + } else { + model.Ttl = "" + } _, err = store.collection.CreateDocument(ctx, model) if driver.IsConflict(err) { return store.UpdateEntry(ctx, entry) @@ -231,6 +242,11 @@ func (store *ArangodbStore) UpdateEntry(ctx context.Context, entry *filer.Entry) Name: name, Meta: bytesToArray(meta), } + if entry.TtlSec > 0 { + model.Ttl = time.Now().Add(time.Duration(entry.TtlSec) * time.Second).Format(time.RFC3339) + } else { + model.Ttl = "none" + } _, err = store.collection.UpdateDocument(ctx, model.Key, model) diff --git a/weed/filer/arangodb/readme.md b/weed/filer/arangodb/readme.md index 24f3a1e7e..eb6411c2e 100644 --- a/weed/filer/arangodb/readme.md +++ b/weed/filer/arangodb/readme.md @@ -43,6 +43,5 @@ should there be one collection per bucket? would make deleting a bucket instant arangodb uses rocksdb in the background, so i am assuming things run in log time -single document retreval might run in constant time - i am not sure how the prefix query scales compared to the recursive calls that some other stores do for folder deletion +might need to change that