简体   繁体   English

存储Google证书的ArangoDB键值

[英]ArangoDB key value to store Google certificates

how do I use promised key value storage in ArangoDB? 如何在ArangoDB中使用承诺的密钥值存储? I want to store Google Certificates in ArangoDB in most effective way or better - most convenient way, which would be associative array resp. 我想以最有效的方式或更好的方式在ArangoDB中存储Google证书 - 最方便的方式,即关联数组。 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 我想出的解决方案是制作一个文件,这个文件对所有密钥都有用,我会像db.Certificates.document('certificates')[hash]那样db.Certificates.document('certificates')[hash]它,其次是存储db.Certificates.insert({'_key': hash, 'value': '.... google certificate ....'})这样的db.Certificates.insert({'_key': hash, 'value': '.... google certificate ....'})我将以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? 也许在某种程度上在RAM而不是数据库存储? I need them to be accessible across all callings of my foxx application and change them when they expire. 我需要在我的foxx应用程序的所有调用中访问它们,并在它们到期时更改它们。 Thanks. 谢谢。

If you don't need the data to be persistent, you can use a volatile collection instead. 如果您不需要数据持久化,则可以使用volatile集合。 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. 易失性集合永远不会同步到磁盘,因此文件(但不是集合本身)将在重新启动之间丢失 - 但它们要快得多,因为数据只存在于RAM中。

You can create a volatile collection like a regular collection by passing the isVolatile option: 您可以通过传递isVolatile选项来创建类似常规集合的volatile集合:

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/Collections/DatabaseMethods.html#create 您可以在创建集合的章节中找到更多信息: https//docs.arangodb.com/Collections/DatabaseMethods.html#create

No, Collections are absolutely the way to go. 不,收藏绝对是最佳选择。

You would parse the json using JSON.parse() , then iterate and save them like this 您将使用JSON.parse()解析json,然后迭代并保存它们

db.certificates.save({_key: hashkey, value: certificate})

and later on fetch it using AQL: 然后使用AQL获取它:

FOR cert IN certificates FILTER _key == '<hashkey>' RETURN cert

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM