Module: ClaudeMemory::Store::RetryHandler
- Included in:
- SQLiteStore
- Defined in:
- lib/claude_memory/store/retry_handler.rb
Overview
Retry logic for SQLite database operations. Handles busy/locked errors from concurrent access by multiple hook processes.
Constant Summary collapse
- MAX_RETRIES =
5- RETRY_BASE_DELAY =
seconds, with exponential backoff
0.1
Instance Method Summary collapse
- #transaction_with_retry(&block) ⇒ Object
- #with_retry(operation_name = "database operation") ⇒ Object
Instance Method Details
#transaction_with_retry(&block) ⇒ Object
26 27 28 29 30 |
# File 'lib/claude_memory/store/retry_handler.rb', line 26 def transaction_with_retry(&block) with_retry("transaction") do @db.transaction(&block) end end |
#with_retry(operation_name = "database operation") ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/claude_memory/store/retry_handler.rb', line 11 def with_retry(operation_name = "database operation") retries = 0 begin yield rescue Sequel::DatabaseError, Extralite::Error, Extralite::BusyError => e if retryable_error?(e) && retries < MAX_RETRIES retries += 1 delay = RETRY_BASE_DELAY * (2**retries) sleep(delay) retry end raise end end |