Skip to content

Commit

Permalink
Use Python's own lru_cache if available
Browse files Browse the repository at this point in the history
  • Loading branch information
hmpf committed Oct 20, 2021
1 parent 09312e0 commit ecdedc3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion python/nav/alertengine/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from datetime import datetime, timedelta

from django.db import transaction, reset_queries
from django.utils.lru_cache import lru_cache

from nav.models.profiles import (
Account,
Expand All @@ -36,6 +35,11 @@
)
from nav.models.event import AlertQueue

try: # Django >= 3
from functools import lru_cache
except ImportError:
from django.utils.lru_cache import lru_cache


_logger = logging.getLogger(__name__)

Expand Down
6 changes: 5 additions & 1 deletion python/nav/metrics/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@

import re

from django.utils.lru_cache import lru_cache
from six import iteritems

from nav.models.manage import Netbox, Interface, Prefix, Sensor

try: # Django >= 3
from functools import lru_cache
except ImportError:
from django.utils.lru_cache import lru_cache

__all__ = ['reverses', 'lookup']
_reverse_handlers = []
Expand Down
6 changes: 5 additions & 1 deletion python/nav/web/ipdevinfo/host_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@


import IPy
from django.utils.lru_cache import lru_cache
from nav import asyncdns

from nav.util import is_valid_ip

try: # Django >= 3
from functools import lru_cache
except ImportError:
from django.utils.lru_cache import lru_cache


def address_sorter(addr_tuple):
"""Return ip object from tuple"""
Expand Down

0 comments on commit ecdedc3

Please sign in to comment.