prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Update asgi look examples to use aioredis 2
  A new major vesion of aioredis was released, and it has some api changes.
  This is the changelog https://github.com/aio-libs/aioredis-py/blob/master/CHANGELOG.md
  
  </issue>
  <code>
  [start of examples/asgilook/asgilook/config.py]
  1 import os
  2 import pathlib
  3 import uuid
  4 
  5 import aioredis
  6 
  7 
  8 class Config:
  9     DEFAULT_CONFIG_PATH = '/tmp/asgilook'
  10     DEFAULT_MIN_THUMB_SIZE = 64
  11     DEFAULT_REDIS_HOST = 'redis://localhost'
  12     DEFAULT_REDIS_POOL = aioredis.create_redis_pool
  13     DEFAULT_UUID_GENERATOR = uuid.uuid4
  14 
  15     def __init__(self):
  16         self.storage_path = pathlib.Path(
  17             os.environ.get('ASGI_LOOK_STORAGE_PATH', self.DEFAULT_CONFIG_PATH)
  18         )
  19         self.storage_path.mkdir(parents=True, exist_ok=True)
  20 
  21         self.create_redis_pool = Config.DEFAULT_REDIS_POOL
  22         self.min_thumb_size = self.DEFAULT_MIN_THUMB_SIZE
  23         self.redis_host = self.DEFAULT_REDIS_HOST
  24         self.uuid_generator = Config.DEFAULT_UUID_GENERATOR
  25
  [end of examples/asgilook/asgilook/config.py]
  [start of examples/asgilook/asgilook/cache.py]
  1 import msgpack
  2 
  3 
  4 class RedisCache:
  5     PREFIX = 'asgilook:'
  6     INVALIDATE_ON = frozenset({'DELETE', 'POST', 'PUT'})
  7     CACHE_HEADER = 'X-ASGILook-Cache'
  8     TTL = 3600
  9 
  10     def __init__(self, config):
  11         self._config = config
  12 
  13         # NOTE(vytas): To be initialized upon application startup (see the
  14         #   method below).
  15         self._redis = None
  16 
  17     async def _serialize_response(self, resp):
  18         data = await resp.render_body()
  19         return msgpack.packb([resp.content_type, data], use_bin_type=True)
  20 
  21     def _deserialize_response(self, resp, data):
  22         resp.content_type, resp.data = msgpack.unpackb(data, raw=False)
  23         resp.complete = True
  24         resp.context.cached = True
  25 
  26     async def process_startup(self, scope, event):
  27         if self._redis is None:
  28             self._redis = await self._config.create_redis_pool(self._config.redis_host)
  29 
  30     async def process_request(self, req, resp):
  31         resp.context.cached = False
  32 
  33         if req.method in self.INVALIDATE_ON:
  34             return
  35 
  36         key = f'{self.PREFIX}/{req.path}'
  37         data = await self._redis.get(key)
  38         if data is not None:
  39             self._deserialize_response(resp, data)
  40             resp.set_header(self.CACHE_HEADER, 'Hit')
  41         else:
  42             resp.set_header(self.CACHE_HEADER, 'Miss')
  43 
  44     async def process_response(self, req, resp, resource, req_succeeded):
  45         if not req_succeeded:
  46             return
  47 
  48         key = f'{self.PREFIX}/{req.path}'
  49 
  50         if req.method in self.INVALIDATE_ON:
  51             await self._redis.delete(key)
  52         elif not resp.context.cached:
  53             data = await self._serialize_response(resp)
  54             await self._redis.set(key, data, expire=self.TTL)
  55
  [end of examples/asgilook/asgilook/cache.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/examples/asgilook/asgilook/cache.py b/examples/asgilook/asgilook/cache.py
  --- a/examples/asgilook/asgilook/cache.py
  +++ b/examples/asgilook/asgilook/cache.py
  @@ -9,10 +9,7 @@
   
       def __init__(self, config):
           self._config = config
  -
  -        # NOTE(vytas): To be initialized upon application startup (see the
  -        #   method below).
  -        self._redis = None
  +        self._redis = self._config.redis_from_url(self._config.redis_host)
   
       async def _serialize_response(self, resp):
           data = await resp.render_body()
  @@ -24,8 +21,10 @@
           resp.context.cached = True
   
       async def process_startup(self, scope, event):
  -        if self._redis is None:
  -            self._redis = await self._config.create_redis_pool(self._config.redis_host)
  +        await self._redis.ping()
  +
  +    async def process_shutdown(self, scope, event):
  +        await self._redis.close()
   
       async def process_request(self, req, resp):
           resp.context.cached = False
  @@ -51,4 +50,4 @@
               await self._redis.delete(key)
           elif not resp.context.cached:
               data = await self._serialize_response(resp)
  -            await self._redis.set(key, data, expire=self.TTL)
  +            await self._redis.set(key, data, ex=self.TTL)
  diff --git a/examples/asgilook/asgilook/config.py b/examples/asgilook/asgilook/config.py
  --- a/examples/asgilook/asgilook/config.py
  +++ b/examples/asgilook/asgilook/config.py
  @@ -9,7 +9,7 @@
       DEFAULT_CONFIG_PATH = '/tmp/asgilook'
       DEFAULT_MIN_THUMB_SIZE = 64
       DEFAULT_REDIS_HOST = 'redis://localhost'
  -    DEFAULT_REDIS_POOL = aioredis.create_redis_pool
  +    DEFAULT_REDIS_FROM_URL = aioredis.from_url
       DEFAULT_UUID_GENERATOR = uuid.uuid4
   
       def __init__(self):
  @@ -18,7 +18,7 @@
           )
           self.storage_path.mkdir(parents=True, exist_ok=True)
   
  -        self.create_redis_pool = Config.DEFAULT_REDIS_POOL
  +        self.redis_from_url = Config.DEFAULT_REDIS_FROM_URL
           self.min_thumb_size = self.DEFAULT_MIN_THUMB_SIZE
           self.redis_host = self.DEFAULT_REDIS_HOST
           self.uuid_generator = Config.DEFAULT_UUID_GENERATOR
  
verification_info: {"golden_diff": "diff --git a/examples/asgilook/asgilook/cache.py b/examples/asgilook/asgilook/cache.py\n--- a/examples/asgilook/asgilook/cache.py\n+++ b/examples/asgilook/asgilook/cache.py\n@@ -9,10 +9,7 @@\n \n     def __init__(self, config):\n         self._config = config\n-\n-        # NOTE(vytas): To be initialized upon application startup (see the\n-        #   method below).\n-        self._redis = None\n+        self._redis = self._config.redis_from_url(self._config.redis_host)\n \n     async def _serialize_response(self, resp):\n         data = await resp.render_body()\n@@ -24,8 +21,10 @@\n         resp.context.cached = True\n \n     async def process_startup(self, scope, event):\n-        if self._redis is None:\n-            self._redis = await self._config.create_redis_pool(self._config.redis_host)\n+        await self._redis.ping()\n+\n+    async def process_shutdown(self, scope, event):\n+        await self._redis.close()\n \n     async def process_request(self, req, resp):\n         resp.context.cached = False\n@@ -51,4 +50,4 @@\n             await self._redis.delete(key)\n         elif not resp.context.cached:\n             data = await self._serialize_response(resp)\n-            await self._redis.set(key, data, expire=self.TTL)\n+            await self._redis.set(key, data, ex=self.TTL)\ndiff --git a/examples/asgilook/asgilook/config.py b/examples/asgilook/asgilook/config.py\n--- a/examples/asgilook/asgilook/config.py\n+++ b/examples/asgilook/asgilook/config.py\n@@ -9,7 +9,7 @@\n     DEFAULT_CONFIG_PATH = '/tmp/asgilook'\n     DEFAULT_MIN_THUMB_SIZE = 64\n     DEFAULT_REDIS_HOST = 'redis://localhost'\n-    DEFAULT_REDIS_POOL = aioredis.create_redis_pool\n+    DEFAULT_REDIS_FROM_URL = aioredis.from_url\n     DEFAULT_UUID_GENERATOR = uuid.uuid4\n \n     def __init__(self):\n@@ -18,7 +18,7 @@\n         )\n         self.storage_path.mkdir(parents=True, exist_ok=True)\n \n-        self.create_redis_pool = Config.DEFAULT_REDIS_POOL\n+        self.redis_from_url = Config.DEFAULT_REDIS_FROM_URL\n         self.min_thumb_size = self.DEFAULT_MIN_THUMB_SIZE\n         self.redis_host = self.DEFAULT_REDIS_HOST\n         self.uuid_generator = Config.DEFAULT_UUID_GENERATOR\n", "issue": "Update asgi look examples to use aioredis 2\nA new major vesion of aioredis was released, and it has some api changes.\r\nThis is the changelog https://github.com/aio-libs/aioredis-py/blob/master/CHANGELOG.md\n", "before_files": [{"content": "import os\nimport pathlib\nimport uuid\n\nimport aioredis\n\n\nclass Config:\n    DEFAULT_CONFIG_PATH = '/tmp/asgilook'\n    DEFAULT_MIN_THUMB_SIZE = 64\n    DEFAULT_REDIS_HOST = 'redis://localhost'\n    DEFAULT_REDIS_POOL = aioredis.create_redis_pool\n    DEFAULT_UUID_GENERATOR = uuid.uuid4\n\n    def __init__(self):\n        self.storage_path = pathlib.Path(\n            os.environ.get('ASGI_LOOK_STORAGE_PATH', self.DEFAULT_CONFIG_PATH)\n        )\n        self.storage_path.mkdir(parents=True, exist_ok=True)\n\n        self.create_redis_pool = Config.DEFAULT_REDIS_POOL\n        self.min_thumb_size = self.DEFAULT_MIN_THUMB_SIZE\n        self.redis_host = self.DEFAULT_REDIS_HOST\n        self.uuid_generator = Config.DEFAULT_UUID_GENERATOR\n", "path": "examples/asgilook/asgilook/config.py"}, {"content": "import msgpack\n\n\nclass RedisCache:\n    PREFIX = 'asgilook:'\n    INVALIDATE_ON = frozenset({'DELETE', 'POST', 'PUT'})\n    CACHE_HEADER = 'X-ASGILook-Cache'\n    TTL = 3600\n\n    def __init__(self, config):\n        self._config = config\n\n        # NOTE(vytas): To be initialized upon application startup (see the\n        #   method below).\n        self._redis = None\n\n    async def _serialize_response(self, resp):\n        data = await resp.render_body()\n        return msgpack.packb([resp.content_type, data], use_bin_type=True)\n\n    def _deserialize_response(self, resp, data):\n        resp.content_type, resp.data = msgpack.unpackb(data, raw=False)\n        resp.complete = True\n        resp.context.cached = True\n\n    async def process_startup(self, scope, event):\n        if self._redis is None:\n            self._redis = await self._config.create_redis_pool(self._config.redis_host)\n\n    async def process_request(self, req, resp):\n        resp.context.cached = False\n\n        if req.method in self.INVALIDATE_ON:\n            return\n\n        key = f'{self.PREFIX}/{req.path}'\n        data = await self._redis.get(key)\n        if data is not None:\n            self._deserialize_response(resp, data)\n            resp.set_header(self.CACHE_HEADER, 'Hit')\n        else:\n            resp.set_header(self.CACHE_HEADER, 'Miss')\n\n    async def process_response(self, req, resp, resource, req_succeeded):\n        if not req_succeeded:\n            return\n\n        key = f'{self.PREFIX}/{req.path}'\n\n        if req.method in self.INVALIDATE_ON:\n            await self._redis.delete(key)\n        elif not resp.context.cached:\n            data = await self._serialize_response(resp)\n            await self._redis.set(key, data, expire=self.TTL)\n", "path": "examples/asgilook/asgilook/cache.py"}]}