<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def log_used_nonce(self, username, iat, nonce):
 """ Log a nonce as being used, and therefore henceforth invalid. :param username: Username as a string. :param iat: Unix timestamp float or integer of when the nonce was used. :param nonce: Nonce value. """

        # TODO: Figure out some way to do this in a thread-safe manner. It'd be better to use
        # a Redis Set or something, but we don't necessarily want to be tightly coupled to
        # Redis either since not everyone uses it.
        key = self.create_nonce_key(username, iat)
        used = cache.get(key, [])
        used.append(nonce)
        cache.set(key, set(used), token.TIMESTAMP_TOLERANCE * 2)