From a6c748390b5be5f50cea65cd9794a3a0bf170193 Mon Sep 17 00:00:00 2001 From: Alexander Verbitsky Date: Mon, 28 Jun 2021 09:29:53 +0300 Subject: [PATCH] S3Driver: performance improvement by caching actively used buckets --- src/cloudstorage/drivers/amazon.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cloudstorage/drivers/amazon.py b/src/cloudstorage/drivers/amazon.py index b21f6f1..7ebc6fe 100644 --- a/src/cloudstorage/drivers/amazon.py +++ b/src/cloudstorage/drivers/amazon.py @@ -2,6 +2,7 @@ import logging from typing import Any, Dict, Iterable, List, TYPE_CHECKING # noqa: F401 from urllib.parse import quote, urljoin +from functools import lru_cache import boto3 from botocore.exceptions import ClientError, ParamValidationError, WaiterError @@ -108,6 +109,7 @@ def _normalize_parameters( return normalized + @lru_cache def _get_bucket(self, bucket_name: str, validate: bool = True): """Get a S3 bucket.