Get a cache entry if it exists. 'item' is of type cryptography.x509.ocsp.OCSPRequest Raises KeyError if the item is not in the cache.
(self, item: OCSPRequest)
| 105 | self._data[cache_key] = value |
| 106 | |
| 107 | def __getitem__(self, item: OCSPRequest) -> OCSPResponse: |
| 108 | """Get a cache entry if it exists. |
| 109 | |
| 110 | 'item' is of type cryptography.x509.ocsp.OCSPRequest |
| 111 | |
| 112 | Raises KeyError if the item is not in the cache. |
| 113 | """ |
| 114 | with self._lock: |
| 115 | cache_key = self._get_cache_key(item) |
| 116 | value = self._data[cache_key] |
| 117 | |
| 118 | # Return cached response if it is still valid. |
| 119 | this_update = _this_update(value) |
| 120 | next_update = _next_update(value) |
| 121 | assert this_update is not None |
| 122 | assert next_update is not None |
| 123 | now = _datetime.now(tz=timezone.utc) |
| 124 | if this_update.tzinfo is None: |
| 125 | # Make naive to match cryptography. |
| 126 | now = now.replace(tzinfo=None) |
| 127 | if this_update <= now < next_update: |
| 128 | return value |
| 129 | |
| 130 | self._data.pop(cache_key, None) |
| 131 | raise KeyError(cache_key) |
nothing calls this directly
no test coverage detected