Local caching with SQLite - hacktlib/py-async-http-logging GitHub Wiki

Async HTTP Logging caches your application log messages in a local SQLite database.

This cache is cleaned up every few seconds[flush frequency] or when the number of log messages reaches a certain threshold[cache size limit]. Log messages are sent in batches to your host.

Cached log messages not sent to the host (due to API downtime, for example) are kept in this local SQLite database.

The next time your application runs, Async HTTP Logging will retry sending of the pending log messages to the host.

If you set a time-to-live[TTL] argument when instantiating the AsyncHttpHandler class, log messages that are old enough will be removed from the local cache and not sent to the host.


Footnotes

[flush frequency] Cached log messages will be sent to the host every five seconds, which you can customize by setting the constants.QUEUED_EVENTS_FLUSH_INTERVAL constant or the QUEUED_EVENTS_FLUSH_INTERVAL environment variable

[cache size limit] When the local cache has 10 or more log messages, the cache is automatically cleared and sent to the host. You can customize this threshold by setting the constants.QUEUED_EVENTS_FLUSH_COUNT constant or the QUEUED_EVENTS_FLUSH_COUNT environment variable.

[TTL] Please refer to the AsyncHttpHandler.event_ttl attribute in the documentation.

⚠️ **GitHub.com Fallback** ⚠️