'Method to store an instance in the cache.
Args:
instance (Class instance): the instance to cache.
new (bool, optional): this is the first time this instance is
cached (i.e. this is not an update operation like after a
db save).'

@classmethod
def cache_instance(cls, instance, new=False):

    pk = instance._get_pk_val()
    if (pk is not None):
        cls.__dbclass__.__instance_cache__[pk] = instance
        if new:
            try:
                instance.at_init()
            except AttributeError:
                pass
