Fixed DB caching, moved to JSON communication

DB caching wasn’t working, changed the SQL commands to utilize ON
DUPLICATE statement.
Moved from php_serialization to json for API, meter for moving forward.