'Returns cache value. If not found and generator function is
given, it will call the generator.
:param key: Cache key.
:param generator: Function to be called to generate a value if `None` is returned.
:param expires: If the key is supposed to be with an expiry, don\'t store it in frappe.local'

def get_value(self, key, generator=None, user=None, expires=False):

    original_key = key
    key = self.make_key(key, user)
    if (key in frappe.local.cache):
        val = frappe.local.cache[key]
    else:
        val = None
        try:
            val = self.get(key)
        except redis.exceptions.ConnectionError:
            pass
        if (val is not None):
            val = pickle.loads(val)
        if (not expires):
            if ((val is None) and generator):
                val = generator()
                self.set_value(original_key, val, user=user)
            else:
                frappe.local.cache[key] = val
    return val
