66from django .conf import settings
77from django .core .cache import DEFAULT_CACHE_ALIAS , caches
88from django .db .models import Model as DjangoModel
9- from django .utils .itercompat import is_iterable
109
1110from .utils import enqueue_task , get_job_class
1211
@@ -29,15 +28,15 @@ def to_bytestring(value):
2928 :returns: a bytestring
3029 """
3130 if isinstance (value , DjangoModel ):
32- return ('%s:%s' % ( value .__class__ , hash (value )) ).encode ('utf-8' )
31+ return (f' { value .__class__ } : { hash (value )} ' ).encode ('utf-8' )
3332 if isinstance (value , str ):
3433 return value .encode ('utf8' )
3534 if isinstance (value , bytes ):
3635 return value
3736 return bytes (str (value ), 'utf8' )
3837
3938
40- class Job ( object ) :
39+ class Job :
4140 """
4241 A cached read job.
4342
@@ -59,7 +58,7 @@ class Job(object):
5958 #: refresh the cache.
6059 refresh_timeout = 60
6160
62- #: Secifies which cache to use from your `CACHES` setting. It defaults to
61+ #: Specifies which cache to use from your `CACHES` setting. It defaults to
6362 #: `default`.
6463 cache_alias = None
6564
@@ -91,7 +90,7 @@ class Job(object):
9190
9291 @property
9392 def class_path (self ):
94- return '%s.%s' % ( self .__module__ , self .__class__ .__name__ )
93+ return f' { self .__module__ } . { self .__class__ .__name__ } '
9594
9695 def __init__ (self ):
9796 self .cache_alias = self .cache_alias or getattr (
@@ -399,11 +398,11 @@ def key(self, *args, **kwargs):
399398 return self .class_path
400399 try :
401400 if args and not kwargs :
402- return "%s:%s" % ( self .class_path , self .hash (args ))
401+ return f" { self .class_path } : { self .hash (args )} "
403402 # The line might break if your passed values are un-hashable. If
404403 # it does, you need to override this method and implement your own
405404 # key algorithm.
406- return "%s:%s:%s:%s" % (
405+ return "{}:{}:{}:{}" . format (
407406 self .class_path ,
408407 self .hash (args ),
409408 self .hash ([k for k in sorted (kwargs )]),
@@ -422,7 +421,7 @@ def hash(self, value):
422421
423422 This is for use in a cache key.
424423 """
425- if is_iterable (value ):
424+ if isinstance (value , collections . abc . Iterable ):
426425 value = tuple (to_bytestring (v ) for v in value )
427426 return hashlib .md5 (b':' .join (value )).hexdigest ()
428427
@@ -440,7 +439,7 @@ def process_result(self, result, call, cache_status, sync_fetch=None):
440439 :param result: The result to be returned
441440 :param call: A named tuple with properties 'args' and 'kwargs that
442441 holds the call args and kwargs
443- :param cache_status: A status integrer , accessible as class constants
442+ :param cache_status: A status integer , accessible as class constants
444443 self.MISS, self.HIT, self.STALE
445444 :param sync_fetch: A boolean indicating whether a synchronous fetch was
446445 performed. A value of None indicates that no fetch
0 commit comments