<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _sync(self):
 """ Synchronize the cached data with the underlyind database. Uses an internal transaction counter and compares to the checkpoint_operations and checkpoint_timeout paramters to determine whether to persist the memory store. In this implementation, this method wraps calls to C{shelve.Shelf#sync}. """

        if (self._opcount > self.checkpoint_operations or
                datetime.now() > self._last_sync + self.checkpoint_timeout):
            self.log.debug("Synchronizing queue metadata.")
            self.queue_metadata.sync()
            self._last_sync = datetime.now()
            self._opcount = 0
        else:
            self.log.debug("NOT synchronizing queue metadata.")