Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possibe to do layeredcache like https://github.com/karlseguin/ccache #132

Closed
hiqbn opened this issue Jun 3, 2019 · 13 comments
Closed

possibe to do layeredcache like https://github.com/karlseguin/ccache #132

hiqbn opened this issue Jun 3, 2019 · 13 comments

Comments

@hiqbn
Copy link

hiqbn commented Jun 3, 2019

layered cache for use for http caching like
https://github.com/karlseguin/ccache

@cristaloleg
Copy link
Collaborator

Hm...so what do you propose exactly? 🤔

@hiqbn
Copy link
Author

hiqbn commented Jun 3, 2019

cache.Set("my-unique-key", "field",[]byte("value"))

entry, _ := cache.Get("my-unique-key","field)

cache.Del("my-unique-key")

@cristaloleg
Copy link
Collaborator

Forgive me, but I don't get it.
Basically we've a cache of...caches, am I get you correctly?

@hiqbn
Copy link
Author

hiqbn commented Jun 3, 2019

sort of cache of caches, more like redis hash functions hset, hget etc.

@hiqbn
Copy link
Author

hiqbn commented Jun 3, 2019

alternatively, how do we achieve the same thing with bigcache?

@cristaloleg
Copy link
Collaborator

1st solution I see:

<cache_name> + <key> : <value>

So basically you've a prefix for each key, which says 'where' this keys is present.

@hiqbn
Copy link
Author

hiqbn commented Jun 3, 2019

ok. thx

@hiqbn hiqbn closed this as completed Jun 3, 2019
@hiqbn hiqbn reopened this Jun 3, 2019
@hiqbn
Copy link
Author

hiqbn commented Jun 3, 2019

key + field = value

i can't clear all key fields with delete(key)
i would like to achieve hset / hget like redis with bigcache. how can i do this?

@cristaloleg
Copy link
Collaborator

Well, you can, you need to iterate over keys and check their prefix (see https://godoc.org/github.com/allegro/bigcache#BigCache.Iterator).
Yes, this is O(|number of keys|) but still a thing 😉

@hiqbn
Copy link
Author

hiqbn commented Jun 3, 2019

that's not very smart. can design one for layeredcache?

@hiqbn
Copy link
Author

hiqbn commented Jun 3, 2019

what other options do we have? smart / efficient way pls.

@cristaloleg
Copy link
Collaborator

I suspect that number of top layers is not very big, and it's also constant (with a high probability).
So making something like map[string]*bigcache.Bigcache will not hurt. Care to try?

@hiqbn
Copy link
Author

hiqbn commented Jun 4, 2019

sounds like a good idea. will implement when i have the time. i'm checking other options first.

@hiqbn hiqbn closed this as completed Jun 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants