Skip to content

Commit f40e846

Browse files
committed
Implement get_non_flushed_event_count() for MemoryCache
Closes #88.
1 parent 1cf3dec commit f40e846

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

logstash_async/cache.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,12 @@ def expire_events(self):
6161
:return:
6262
"""
6363
pass
64+
65+
# ----------------------------------------------------------------------
66+
@abstractmethod
67+
def get_non_flushed_event_count(self):
68+
"""Determine the count of pending events in the cache which need to be sent to Logstash.
69+
70+
:return: Count of pending events
71+
"""
72+
pass

logstash_async/memory_cache.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,7 @@ def _delete_events(self, ids_to_delete):
9393
self.logger.warning(
9494
"Could not delete event with id %s. It does not appear to be in the cache.",
9595
event_id)
96+
97+
# ----------------------------------------------------------------------
98+
def get_non_flushed_event_count(self):
99+
return len([event for event in self._cache.values() if not event['pending_delete']])

0 commit comments

Comments
 (0)