(self)
| 237 | |
| 238 | @cached_property |
| 239 | def session_id(self): |
| 240 | if (cached_data := self._reader.read(self.cache_key)) is not None: |
| 241 | # Cache hit, but session id is expired. Generate new id and update. |
| 242 | if ( |
| 243 | cached_data.timestamp + _SESSION_LENGTH_SECONDS |
| 244 | < self._timestamp |
| 245 | ): |
| 246 | cached_data.session_id = self._session_id |
| 247 | # Always update the timestamp to last used. |
| 248 | cached_data.timestamp = self._timestamp |
| 249 | self._writer.write(cached_data) |
| 250 | return cached_data.session_id |
| 251 | # Cache miss, generate and write new record. |
| 252 | session_id = self._session_id |
| 253 | session_data = CLISessionData( |
| 254 | self.cache_key, session_id, self._timestamp |
| 255 | ) |
| 256 | self._writer.write(session_data) |
| 257 | return session_id |
| 258 | |
| 259 | @cached_property |
| 260 | def _tty(self): |
nothing calls this directly
no test coverage detected