(domain: str, key: str, value: str)
| 57 | |
| 58 | |
| 59 | def put(domain: str, key: str, value: str) -> None: |
| 60 | conn = _db_conn() |
| 61 | conn.execute( |
| 62 | "UPDATE ghstack_cache SET value = ? WHERE domain = ? AND key = ?", |
| 63 | (value, domain, key), |
| 64 | ) |
| 65 | c = conn.execute( |
| 66 | """ |
| 67 | INSERT INTO ghstack_cache (domain, key, value) |
| 68 | SELECT ?, ?, ? WHERE (SELECT Changes() = 0) |
| 69 | """, |
| 70 | (domain, key, value), |
| 71 | ) |
| 72 | if c.lastrowid is not None: |
| 73 | conn.execute( |
| 74 | "DELETE FROM ghstack_cache WHERE id < ?", (c.lastrowid - CACHE_SIZE,) |
| 75 | ) |
| 76 | conn.commit() |
nothing calls this directly
no test coverage detected