Implemented caching throught ets tables (cached and pending to be cached) and periodic cleanup of pending flags + setting new flags describing need of transition between pending and cached tables. There is a possibility of failure if there will be too many records in pending table. Possible next solution is to remove each record which has ratio too low in comparison to other records and is therefore considered not frequently needed.