Skip to content

Commit

Permalink
add new db table for did cache
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBuchanan314 committed Dec 23, 2024
1 parent b837ab6 commit 0b2dcd1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/millipds/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,19 @@ def _init_tables(self):
"""
)

# we cache failures too, represented as a null doc (with shorter TTL)
# timestamps are unix timestamp ints, in seconds
self.con.execute(
"""
CREATE TABLE did_cache(
did TEXT PRIMARY KEY NOT NULL,
doc TEXT,
created_at INTEGER NOT NULL,
expires_at INTEGER NOT NULL,
)
"""
)

def update_config(
self,
pds_pfx: Optional[str] = None,
Expand Down
3 changes: 3 additions & 0 deletions src/millipds/static_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@
100 # might want to tweak this upwards on a very active PDS
)
# NB: each firehose event can be up to ~1MB, but on average they're much smaller

DID_TTL = 60 * 60 * 24 # 1 day
DID_ERROR_TTL = 60 * 5 # 5 mins

0 comments on commit 0b2dcd1

Please sign in to comment.