'Retrieve data from cache or re-generate and re-cache data if
stale/non-existant. If ``max_age`` is 0, return cached data no
matter how old.
:param name: name of datastore
:param data_func: function to (re-)generate data.
:type data_func: ``callable``
:param max_age: maximum age of cached data in seconds
:type max_age: ``int``
:returns: cached data, return value of ``data_func`` or ``None``
if ``data_func`` is not set'

def cached_data(self, name, data_func=None, max_age=60):

    serializer = manager.serializer(self.cache_serializer)
    cache_path = self.cachefile((u'%s.%s' % (name, self.cache_serializer)))
    age = self.cached_data_age(name)
    if (((age < max_age) or (max_age == 0)) and os.path.exists(cache_path)):
        with open(cache_path, u'rb') as file_obj:
            self.logger.debug(u'Loading    cached    data    from    :    %s', cache_path)
            return serializer.load(file_obj)
    if (not data_func):
        return None
    data = data_func()
    self.cache_data(name, data)
    return data
