Do not query database for every metadata_get

This change stores the rsrc_metadata locally when the Resource object
is created so that the database is not queried every time
metadata_get is called. There are some instances where the metadata
must come from the database (eg, polling for waitcondition signal) so
an optional refresh arg is added to metadata_get to force a database
refresh of the stored rsrc_metadata.

This results in one less sql query for every time metadata_get is called,
which will help the optimising effort for
Related-Bug: #1306743

Change-Id: Iad2d810c299347ae3b6a4a8329bbd314ee4b5c16
Merge "Do not query database for every metadata_get"