File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,10 @@ def init(self):
111
111
self ._tagging_objects [key ].append (tag )
112
112
self .logger .debug ("Generated tags: %r." , self ._tagging_objects )
113
113
114
+ if self .current_events and self .cache_length ():
115
+ # Ensure we do generate feed on reload / restart
116
+ self ._generate_feed ()
117
+
114
118
def _load_event (self , file_path : Path , key : str ):
115
119
if file_path .exists ():
116
120
self .current_events [key ] = MISPEvent ()
Original file line number Diff line number Diff line change 15
15
class CacheMixin :
16
16
"""Provides caching possibilities for bots
17
17
18
- For key-value cache, use methods:
19
- cache_exists
20
- cache_get
21
- cache_set
22
-
23
- To store dict elements in a cache queue named after bot id, use methods:
24
- cache_put
25
- cache_pop
18
+ For key-value cache, use methods:
19
+ cache_exists
20
+ cache_get
21
+ cache_set
22
+
23
+ To store dict elements in a cache queue named after bot id, use methods:
24
+ cache_put
25
+ cache_pop
26
+ cache_length
26
27
"""
28
+
27
29
__redis : redis .Redis = None
28
30
redis_cache_host : str = "127.0.0.1"
29
31
redis_cache_port : int = 6379
@@ -70,6 +72,9 @@ def cache_put(self, value: dict) -> int:
70
72
size = self .__redis .lpush (self .bot_id , json .dumps (value ))
71
73
return size
72
74
75
+ def cache_length (self ) -> int :
76
+ return self .__redis .llen (self .bot_id )
77
+
73
78
def cache_pop (self ) -> dict :
74
79
data = self .__redis .rpop (self .bot_id )
75
80
if data is None :
You can’t perform that action at this time.
0 commit comments