I added cache ‘reset’ and ‘add’ apis this week. Reset api allows to evict a file out of the cache pool altogether. Add api creates a temporary storage (by creating a tmp file and unlinking it) and then caches the data. Add can even be used to overlay a certain resource over another cached file.
reset api is as follows: get request to /cache/reset/(uri for the file)
add api: post request with file data to /cache/add/(uri for the new file)
curl -d ‘hello world’ localhost:2001/cache/add/first/file # will add a new file with contents hello world
curl localhost:2001/first/file # should display hello world
curl localhost:2001/reset/first/file # should evict the file out of memory, should get 404 when trying to get first/file now
The webui now has ability to delete files through the ui. Its still pretty basic but I plan to improve it next week.
Internally a lot of changes happened. I added a pipe pool this week, for combining the pipe consumtions of requests and file caches. But it turned out to be a bad idea at the end as it was a thread local cache and pipes were unevenly divided in different threads when releasing cached files. At the end I decided to let requests keep the pipes in their cache and only support pipe pool for files. I added more control in the memory usage pattern, by allowing to set (for now static constants) pipe pool and request cache pool limits. Setting both to zero will bring the resources down to zero when everything is evicted and no request is pending. I will add an api to configure this soon.
For this week, thats it folks!
Github account for the project: https://github.com/ziahamza/monkey-cache