Using a relay as a key-value store #1218
alexgleason
started this conversation in
Ideas
Replies: 2 comments 2 replies
-
This looks similar to #1168. I used kind I think @wilsonsilva is considering something like that from this convo: wilsonsilva/nostr#13 |
Beta Was this translation helpful? Give feedback.
0 replies
-
But as of now, you can put all your app's key-value pairs as NIP-78 tags: https://github.com/nostr-protocol/nips/blob/master/78.md |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Some popular relays like strfry use a key-value store (LMDB) as its database. But what if you could use strfry directly as a key-value store?
Why? Well, I don't know. My application uses a key-value store and I wonder if I can do everything through events.
Anyway, implementing
get
andset
is easy.getMany
is the hard part, because it's a range query and relays don't guarantee ordering.But wait, they do! They order by created_at desc.
So we just have to encode the keys as created_at timestamps. We just need some fancy numerical key compression algorithm, or, to map keys to numbers manually. And yes we are limited by the JSON integer range. But then we can do range queries with
since
anduntil
filters.Is this good? Is this useful? Is this practical? No, not at all. It's not my best idea. But something about it burns in my brain so I can't help posting it.
Beta Was this translation helpful? Give feedback.
All reactions