Classes
ParseCache
2
▼
Protocol for content-addressed parse caches.
Cache key is (content_hash, config_hash). Cached valu…
ParseCache
2
▼
Protocol for content-addressed parse caches.
Cache key is (content_hash, config_hash). Cached value is Document (AST). Document is immutable, safe to share across threads.
Methods
get
2
Document | None
▼
Return cached Document if present, else None.
get
2
Document | None
▼
def get(self, content_hash: str, config_hash: str) -> Document | None
Parameters
| Name | Type | Description |
|---|---|---|
content_hash |
— |
|
config_hash |
— |
Returns
Document | None
put
3
▼
Store Document in cache.
put
3
▼
def put(self, content_hash: str, config_hash: str, doc: Document) -> None
Parameters
| Name | Type | Description |
|---|---|---|
content_hash |
— |
|
config_hash |
— |
|
doc |
— |
DictParseCache
3
▼
In-memory parse cache using a dict.
Not thread-safe. For parallel parsing, wrap with a lock or use…
DictParseCache
3
▼
In-memory parse cache using a dict.
Not thread-safe. For parallel parsing, wrap with a lock or use a thread-safe implementation.
Methods
get
2
Document | None
▼
Return cached Document if present, else None.
get
2
Document | None
▼
def get(self, content_hash: str, config_hash: str) -> Document | None
Parameters
| Name | Type | Description |
|---|---|---|
content_hash |
— |
|
config_hash |
— |
Returns
Document | None
put
3
▼
Store Document in cache.
put
3
▼
def put(self, content_hash: str, config_hash: str, doc: Document) -> None
Parameters
| Name | Type | Description |
|---|---|---|
content_hash |
— |
|
config_hash |
— |
|
doc |
— |
Internal Methods 1 ▼
__init__
0
▼
__init__
0
▼
def __init__(self) -> None
Functions
hash_content
1
str
▼
Compute SHA256 hash of source for cache key.
hash_content
1
str
▼
def hash_content(source: str) -> str
Parameters
| Name | Type | Description |
|---|---|---|
source |
str |
Markdown source text |
Returns
str
hash_config
1
str
▼
Compute hash of ParseConfig for cache key.
When text_transformer is set, retur…
hash_config
1
str
▼
def hash_config(config: ParseConfig) -> str
Compute hash of ParseConfig for cache key.
When text_transformer is set, returns empty string to disable caching (transformer affects output in non-hashable way).
Parameters
| Name | Type | Description |
|---|---|---|
config |
ParseConfig |
ParseConfig to hash |
Returns
str