Introduce caching to DiscreteRegistry.

Cached representation of state on disk is kept in the memory
after API query until next time data is dump to disk. Second and
following API queries will not hit the disk.
Other improvements and bug fixes.

Bug: 176965672
Test: in development
Change-Id: I583cba4c74487c79f023efd4b3ce2ee844351719
2 files changed