Serializes the database file to disk.

        Args:
            force (bool): when True, the elapsed time since last save is ignored
                and the database is saved anyway (subject to global
                :data:`writeable` setting).

def save(self, force=False):
        """Serializes the database file to disk.

        Args:
            force (bool): when True, the elapsed time since last save is ignored
                and the database is saved anyway (subject to global
                :data:`writeable` setting).
        """
        from time import time

        # Since the DBs can get rather large, we don't want to save them every
        # single time a method is called. Instead, we only save them at the
        # frequency specified in the global settings file.
        from datetime import datetime
        savefreq = TaskDB.get_option("savefreq", 2, int)
        
        if self.lastsave is not None:
            delta = (datetime.fromtimestamp(time()) -
                     datetime.fromtimestamp(self.lastsave)) 
            elapsed = int(delta.total_seconds()/60)
        else:
            elapsed = savefreq + 1

        if elapsed > savefreq or force:
            if not writeable:
                #We still overwrite the lastsave value so that this message doesn't
                #keep getting output for every :meth:`record` call.
                self.lastsave = time()
                msg.std("Skipping database write to disk by setting.", 2)
                return

            import json
            try:
                entities, compkeys = _json_clean(self.entities)
                jdb = {"entities": entities,
                       "compkeys": compkeys,
                       "uuids": self.uuids}
                with open(self.dbpath, 'w') as f:
                    json.dump(jdb, f)
            except: # pragma: no cover
                from acorn.msg import err
                import sys
                raise
                err("{}: {}".format(*sys.exc_info()[0:2]))

            self.lastsave = time()