MCPcopy Create free account
hub / github.com/ezyang/ghstack / put

Function put

src/ghstack/cache.py:59–76  ·  view source on GitHub ↗
(domain: str, key: str, value: str)

Source from the content-addressed store, hash-verified

57
58
59def 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()

Callers

nothing calls this directly

Calls 1

_db_connFunction · 0.85

Tested by

no test coverage detected