Closed subins2000 closed 3 years ago
This is pretty straight forward. We can do it. Should I create a new PR or update existing one ?
@joicemjoseph What would be the best way to do this ? I don't know Go much, but from a general POV, I was thinking maybe create a local HashMap on runtime that store frequent words with hitcount. The low hit words in the map gets removed every now and then (interval, perhaps a day)
I tried to write a echo middleware and failed. Initially I thought it is simple and straight forward, but it was not. As per our implementation, varnamc and varnamd resides in same machine. and both querying and cache lookup will cost almost same. So, I think can be marked as low priority. (sorry for the late reply)
@joicemjoseph What's the challenge in the cache part ? From seeing the code, I infer it will now take 100MB RAM for the cache part. I think it's enough. A further enhancement would be clearing cache at intervals according to hit measurement, but let's have that later.
Thank you for your contributions and insights :)
Clearing cache, etc are managed.
What's the challenge in the cache part ?
As I mentioned, I tried to add cache on echo. as a middleware. This implementation is caching on handler. That is the difference. It was hard to do in echo (OR I don't know how to do)
Performance can be improved if requests to
/tl
and/rtl
is cached to avoid hitting database for fetching result. For a public API server setup, what would be the nice way to do this ?cc @athul @joicemjoseph