Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit fa58857

Browse files
committed
[client] Put live stream information in cache (#838)
1 parent 8dab3f3 commit fa58857

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pycti/connector/opencti_connector_helper.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,9 @@ class TimeUnit(Enum):
769769
def __init__(self, config: Dict, playbook_compatible=False) -> None:
770770
sys.excepthook = killProgramHook
771771

772+
# Cache
773+
self.stream_collections = {}
774+
772775
# Load API config
773776
self.config = config
774777
self.opencti_url = get_config_variable(
@@ -1063,6 +1066,9 @@ def get_stream_collection(self):
10631066
"stream_live": True,
10641067
"stream_public": False,
10651068
}
1069+
# Get from cache
1070+
elif self.connect_live_stream_id in self.stream_collections:
1071+
return self.stream_collections[self.connect_live_stream_id]
10661072
else:
10671073
query = """
10681074
query StreamCollection($id: String!) {
@@ -1076,6 +1082,10 @@ def get_stream_collection(self):
10761082
}
10771083
"""
10781084
result = self.api.query(query, {"id": self.connect_live_stream_id})
1085+
# Put in cache
1086+
self.stream_collections[self.connect_live_stream_id] = result["data"][
1087+
"streamCollection"
1088+
]
10791089
return result["data"]["streamCollection"]
10801090
else:
10811091
raise ValueError("This connector is not connected to any stream")

0 commit comments

Comments
 (0)