This is my second time diving into the vast ocean of Poco Cache library source code. And since this is my second time studying it, I actually get a much better understanding and overview of how the Poco Cache really works. It works by event handling. The moment there is a need for the elements to be removed, it will fire an event to notify the strategy on which elements it would like to remove, and it will then pass back these elements to be undergone actual removal operation. However, there is a drawback to this, you can’t do anything to the cache upon its expiration using Poco’s own library. Nevertheless, there’s a catch here. We can define our own strategy to do something to the parameters passing around before it goes expired.

Here comes the problem.  The keys are only passed around but not the values. And even if you are trying to read the value from the key, it will make some modification to the cache data itself such as the ordering of the elements. I have been spending days and night trying to figure out how to sort this out. A lot of ideas keep streaming into my mind like trying to make a callback using rest api method(server sending request to server itself), passing down the resource memory upon initialization of the cache data(which gives rise to the problem of circular dependency), trying to call the cache data through event sender pointer(but it’s a const void pointer in which only constant functions can be used) , overloading the derived class function and etc, but none of these really work well and each has their respective problem. Finally and very fortunately, the entire problem has been solved by implenting a very simple method, that is, declare a new unordered map data  memory which copies the cache data and keeps track of the cache data, and use the key from the expired cache data to get the value from this “doppelganger”.  doppelganger

I’m very glad that the critical problem has been solved, but more problems are awaiting me in the future to solve. For instance, trying to integrate dropbox sdk javascript into admin-on-rest, which is also another horrible challenge because the javascript version of admin-on-rest is terribly hard to read and understand. And it consists of different modules and frameworks such as ES6, Material UI, Node.js, React and so much more. I know it’s not gonna be simple to translate the very primitive version of javascript into this high-level modern version of script.


1 Comment

Cache Me if you Can – Blog@AESTE · 2018-06-13 at 12:03

[…] a previous intern already figured out how to implement the cache using the Poco C++ libraries. All I have to do is […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.