Cache & Storage API¶
Two-layer cache: SQLite (always-on) + Redis (optional). Results are stored as JSON-serialized DomainResult objects with a configurable TTL.
Cache store¶
coldreach.storage.cache ¶
Local result cache for ColdReach domain scans.
Two-layer cache: 1. SQLite — always available, stored at ~/.coldreach/cache.db 2. Redis — optional faster layer; used when redis_url is configured
Both layers use a 7-day TTL by default (configurable).
DomainResult objects are round-tripped via Pydantic JSON (model_dump_json / model_validate_json), preserving all fields including nested EmailRecord and SourceRecord objects.
Thread safety: SQLite connections are per-instance (not shared across threads). For concurrent callers, instantiate one CacheStore per thread or rely on SQLite's built-in WAL locking.
CacheStore ¶
SQLite-backed domain result cache with optional Redis layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db_path
|
str | None
|
Path to the SQLite database file. |
_DEFAULT_DB
|
redis_url
|
str | None
|
Redis connection URL, e.g. |
None
|
ttl_days
|
int
|
How long to keep cached results before they expire. |
_DEFAULT_TTL_DAYS
|
Source code in coldreach/storage/cache.py
get ¶
Return a cached DomainResult for domain, or None on miss/expiry.
Source code in coldreach/storage/cache.py
set ¶
Store result for domain in all available cache layers.
Source code in coldreach/storage/cache.py
clear ¶
Delete cached entries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
domain
|
str | None
|
If given, delete only that domain. Otherwise delete everything. |
None
|
Returns:
| Type | Description |
|---|---|
int
|
Number of SQLite rows deleted. |
Source code in coldreach/storage/cache.py
list_domains ¶
Return all cached domains as (domain, cached_at, is_expired) tuples.
Source code in coldreach/storage/cache.py
stats ¶
Return basic cache statistics.
Source code in coldreach/storage/cache.py
Finder config & orchestration¶
coldreach.core.finder ¶
find_emails() — the main orchestrator.
Runs all configured sources concurrently, deduplicates results, runs the verification pipeline on each candidate, and returns a ranked DomainResult.
Design
- Sources run in parallel via asyncio.gather (fire-and-forget per source)
- Each source's results are merged into a shared email→SourceRecord map
- After all sources complete, the verification pipeline scores each email
- Final DomainResult is sorted by confidence descending
Source precedence for confidence_hint (added on top of pipeline score): website/contact +35 website/team +30 website/about +25 github/commit +25 whois +20 reddit +15 website/generic +15
FinderConfig
dataclass
¶
FinderConfig(
use_web_crawler=True,
use_whois=True,
use_github=True,
use_reddit=True,
use_search_engine=True,
use_intelligent_search=True,
use_harvester=True,
use_spiderfoot=True,
use_firecrawl=False,
use_crawl4ai=False,
use_role_emails=True,
github_token=None,
searxng_url="http://localhost:8088",
firecrawl_url="http://localhost:3002",
brave_api_key=None,
spiderfoot_container="coldreach-spiderfoot",
spiderfoot_max_wait=180.0,
harvester_container="coldreach-theharvester",
harvester_max_wait=240.0,
background_slow_sources=False,
harvester_sources=None,
reacher_url="http://localhost:8083",
use_reacher=True,
use_holehe=False,
cache_db="~/.coldreach/cache.db",
redis_url=None,
cache_ttl_days=7,
use_cache=True,
refresh_cache=False,
min_confidence=0,
request_timeout=10.0,
max_concurrent_sources=6,
)
Runtime options for find_emails().
Attributes:
| Name | Type | Description |
|---|---|---|
use_web_crawler |
bool
|
Crawl company website pages. |
use_whois |
bool
|
Query WHOIS for registrant contact emails. |
use_github |
bool
|
Mine public GitHub commits for domain emails. |
use_reddit |
bool
|
Search Reddit for domain email mentions. |
github_token |
str | None
|
Optional GitHub PAT for higher rate limits (5000/hr vs 60/hr). |
min_confidence |
int
|
Exclude emails below this confidence from the final result. |
request_timeout |
float
|
Per-source HTTP timeout in seconds. |
max_concurrent_sources |
int
|
Maximum number of sources to run simultaneously. |
find_emails
async
¶
Discover and verify all email addresses for domain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
domain
|
str
|
Target domain, e.g. |
required |
person_name
|
str | None
|
Optional full name for pattern-based narrowing. |
None
|
config
|
FinderConfig | None
|
Finder configuration. Uses sensible defaults if not provided. |
None
|
Returns:
| Type | Description |
|---|---|
DomainResult
|
All discovered, verified, and ranked email addresses for domain. |
Source code in coldreach/core/finder.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | |