timshannon / badgerhold

BadgerHold is an embeddable NoSQL store for querying Go types built on Badger
MIT License
514 stars 52 forks source link

Feature Request: Metadata on keys and then supporting that metadata value to filter search results. #96

Open PD-Pramila opened 1 year ago

timshannon commented 1 year ago

You can access the badger DB yourself with store.Badger() and set TTL and metadata:

https://dgraph.io/docs/badger/get-started/#setting-time-to-live-ttl-and-user-metadata-on-keys

PD-Pramila commented 1 year ago

Thanks. That's true, I checked that. But it will not consider the metadata value, during find aggregate and queries in that search, right?

What we want to achieve is , for each key-value pair, have a ref count. I thought if I can save that as part of metadata, instead of value, then updates will be fast. It will just update the metadata and not the entire value of the key on disk. Is that understanding right? Then we can query all keys with ref count as zero and do some processing, instead of searching value part for all keys and then filter where ref count is zero.

Any idea how to achieve it?

PD-Pramila commented 1 year ago

Can you also explain how to use it, if I have to use from Badger DB. I am using store.TxInsert(...), which internally calls, Txn.Set., where it calls NewEntry and SetEntry. I want to use all encoding and other stuff done in store.TxInsert. Now if this is the way to add metadata, while creating new entry: e := badger.NewEntry([]byte("answer"), []byte("42")).WithMeta(byte(1)).WithTTL(time.Hour) err := txn.SetEntry(e)

How to add metadata and TTL while using TxInsert? Is there any way to do it during TxInsert or after it, before committing Txn?

tauraamui commented 11 months ago

If you want to find content based on meta data stored in keys, I am not sure but I would suspect that the meta data is actually stored in the vlog anyways.

PD-Pramila commented 11 months ago

@tauraamui Thanks for your comments. Can you please answer my prev question: How to add metadata and TTL while using TxInsert of badgerhold? Is there any way to do it during TxInsert or after it, before committing Txn?

tauraamui commented 10 months ago

I don't know if you can do this with Badgerhold, I doubt it.

timshannon commented 10 months ago

yep, you should definitely use kvs.

tauraamui commented 10 months ago

This thread hasn't referred to KVS, what?

PD-Pramila commented 10 months ago

@timshannon @tauraamui What is KVS?

We need TTL and metadata with badgerhold DB, any plans for that?