Skip to content

Commit

Permalink
Implement get_non_flushed_event_count() for MemoryCache
Browse files Browse the repository at this point in the history
Closes #88.
  • Loading branch information
eht16 committed Sep 14, 2023
1 parent 1cf3dec commit f40e846
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions logstash_async/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,12 @@ def expire_events(self):
:return:
"""
pass

# ----------------------------------------------------------------------
@abstractmethod
def get_non_flushed_event_count(self):
"""Determine the count of pending events in the cache which need to be sent to Logstash.
:return: Count of pending events
"""
pass
4 changes: 4 additions & 0 deletions logstash_async/memory_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,7 @@ def _delete_events(self, ids_to_delete):
self.logger.warning(
"Could not delete event with id %s. It does not appear to be in the cache.",
event_id)

# ----------------------------------------------------------------------
def get_non_flushed_event_count(self):
return len([event for event in self._cache.values() if not event['pending_delete']])

0 comments on commit f40e846

Please sign in to comment.