old_contents: from werkzeug.contrib.cache import (NullCache, SimpleCache, MemcachedCache,
                                      GAEMemcachedCache, FileSystemCache)
  
  def null(app, args, kwargs):
      return NullCache()
  
  def simple(app, args, kwargs):
      kwargs.update(dict(threshold=app.config['CACHE_THRESHOLD']))
      return SimpleCache(*args, **kwargs)
  
  def memcached(app, args, kwargs):
      args.append(app.config['CACHE_MEMCACHED_SERVERS'])
      kwargs.update(dict(key_prefix=app.config['CACHE_KEY_PREFIX']))
      return MemcachedCache(*args, **kwargs)
  
  def gaememcached(app, args, kwargs):
      kwargs.update(dict(key_prefix=app.config['CACHE_KEY_PREFIX']))
      return GAEMemcachedCache(*args, **kwargs)
  
  def filesystem(app, args, kwargs):
      args.append(app.config['CACHE_DIR'])
      kwargs.update(dict(threshold=app.config['CACHE_THRESHOLD']))
      return FileSystemCache(*args, **kwargs)
  
  # RedisCache is supported since Werkzeug 0.7.
  try:
      from werkzeug.contrib.cache import RedisCache
  except ImportError:
      pass
  else:
      def redis(app, args, kwargs):
          kwargs.update(dict(
              host=app.config.get('CACHE_REDIS_HOST', 'localhost'),
              port=app.config.get('CACHE_REDIS_PORT', 6379),
          ))
          password = app.config.get('CACHE_REDIS_PASSWORD')
          if password:
              kwargs['password'] = password
  
          return RedisCache(*args, **kwargs)
  
  
new_contents: from werkzeug.contrib.cache import (NullCache, SimpleCache, MemcachedCache,
                                      GAEMemcachedCache, FileSystemCache)
  
  def null(app, args, kwargs):
      return NullCache()
  
  def simple(app, args, kwargs):
      kwargs.update(dict(threshold=app.config['CACHE_THRESHOLD']))
      return SimpleCache(*args, **kwargs)
  
  def memcached(app, args, kwargs):
      args.append(app.config['CACHE_MEMCACHED_SERVERS'])
      kwargs.update(dict(key_prefix=app.config['CACHE_KEY_PREFIX']))
      return MemcachedCache(*args, **kwargs)
  
  def gaememcached(app, args, kwargs):
      kwargs.update(dict(key_prefix=app.config['CACHE_KEY_PREFIX']))
      return GAEMemcachedCache(*args, **kwargs)
  
  def filesystem(app, args, kwargs):
      args.append(app.config['CACHE_DIR'])
      kwargs.update(dict(threshold=app.config['CACHE_THRESHOLD']))
      return FileSystemCache(*args, **kwargs)
  
  # RedisCache is supported since Werkzeug 0.7.
  try:
      from werkzeug.contrib.cache import RedisCache
  except ImportError:
      pass
  else:
      def redis(app, args, kwargs):
          kwargs.update(dict(
              host=app.config.get('CACHE_REDIS_HOST', 'localhost'),
              port=app.config.get('CACHE_REDIS_PORT', 6379),
          ))
          password = app.config.get('CACHE_REDIS_PASSWORD')
          if password:
              kwargs['password'] = password
  
          key_prefix = app.config.get('CACHE_KEY_PREFIX')
          if key_prefix:
              kwargs['key_prefix'] = key_prefix
  
          return RedisCache(*args, **kwargs)
  
  
subject: Make CACHE_KEY_PREFIX work for RedisCache. It is available for Werkzeug >= 0.8.1.