'this method will either create an instance (by calling the default implementation)
or try to retrieve one from the class-wide cache by inferring the pk value from
`args` and `kwargs`. If instance caching is enabled for this class, the cache is
populated whenever possible (ie when it is possible to infer the pk value).'

def __call__(cls, *args, **kwargs):

    def new_instance():
        return super(SharedMemoryModelBase, cls).__call__(*args, **kwargs)
    instance_key = cls._get_cache_key(args, kwargs)
    if (instance_key is None):
        return new_instance()
    cached_instance = cls.get_cached_instance(instance_key)
    if (cached_instance is None):
        cached_instance = new_instance()
        cls.cache_instance(cached_instance, new=True)
    return cached_instance
