So I'm writing a webservice that uses Redis as a cache. However, I'd like for the Redis instance to not be completely necessary when I'm working in development mode, or if the cache goes down for some reason, the rest of my code keeps running. Is there a way to wrap all the functions in a class/object (ex. the Redis scala client) so that if any of those functions are called and some condition is not met, I can add custom handling to every function?
I'm thinking something like:
object MyWrapper extends RedisClient {
def onAnyRedisClientFunctionCall(f : Any => Any) : Any = {
redisClient match {
case Some(client) => f
case None => // log to error, return something else, etc.
}
}
}