Skip to content

Commit

Permalink
👌 [#3489] PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-maertens committed Sep 27, 2023
1 parent 355b4a0 commit 792b7de
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/openforms/contrib/kadaster/api/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from functools import partial

from django.core.cache import caches
from django.core.cache import cache
from django.utils.translation import gettext_lazy as _

from drf_spectacular.types import OpenApiTypes
Expand All @@ -13,6 +13,7 @@

from openforms.api.serializers import ExceptionSerializer, ValidationErrorSerializer
from openforms.api.views.mixins import ListMixin
from openforms.contrib.kadaster.clients.bag import AddressResult
from openforms.submissions.api.permissions import AnyActiveSubmissionPermission

from ..clients import get_bag_client, get_locatieserver_client
Expand All @@ -32,7 +33,7 @@
) # 24 hours - address data does NOT update frequently


def lookup_address(postcode: str, number: str):
def lookup_address(postcode: str, number: str) -> AddressResult | None:
with get_bag_client() as client:
return client.get_address(postcode, number)

Expand Down Expand Up @@ -79,7 +80,7 @@ def get(self, request, *args, **kwargs):

# check the cache so we avoid hitting the remote API too often (and risk
# of being throttled, see #1832)
address_data = caches["default"].get_or_set(
address_data = cache.get_or_set(
key=f"BAG|get_address|{postcode}|{number}",
default=partial(lookup_address, postcode, number),
timeout=ADDRESS_AUTOCOMPLETE_CACHE_TIMEOUT,
Expand Down

0 comments on commit 792b7de

Please sign in to comment.