Search code examples
google-apikey-valuearangodbfoxx

ArangoDB key value to store Google certificates


how do I use promised key value storage in ArangoDB? I want to store Google Certificates in ArangoDB in most effective way or better - most convenient way, which would be associative array resp. key-value. But i can not find anything about it in database.

Solutions I came up with are to make one document which would be wtorage for all keys and I'd acces it like db.Certificates.document('certificates')[hash] and second is to store documents like db.Certificates.insert({'_key': hash, 'value': '.... google certificate ....'}) which would I access as db.Certificates.document(hash).value

I don't like those solutions since they don't seem right, values are one level deeper as I'd expect from key-value storage. Or is there any faster way to store certificates? Maybe somehow in RAM instead of db storage? I need them to be accessible across all callings of my foxx application and change them when they expire. Thanks.


Solution

  • If you don't need the data to be persistent, you can use a volatile collection instead. Volatile collections will never be synced to disk so documents (but not the collection itself) will be lost between restarts -- but they are quite a bit faster because the data only lives in RAM.

    You can create a volatile collection like a regular collection by passing the isVolatile option:

    var db = require('org/arangodb').db;
    var volatileCollection = db._create('temp', {isVolatile: true});
    

    You can find more information in the chapter on creating collections: https://docs.arangodb.com/3.11/develop/javascript-api/@arangodb/db-object/#db_createcollection-name--properties--type--options