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

Commit b52644c

Browse files
committed
[client] Replace dict by proper caching
1 parent 9453a5a commit b52644c

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

pycti/utils/opencti_stix2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import datefinder
1111
import dateutil.parser
1212
import pytz
13+
from cachetools import TTLCache
1314

1415
from pycti.api import LOGGER as API_LOGGER
1516
from pycti.entities.opencti_identity import Identity
@@ -42,7 +43,7 @@ class OpenCTIStix2:
4243
def __init__(self, opencti):
4344
self.opencti = opencti
4445
self.stix2_update = OpenCTIStix2Update(opencti)
45-
self.mapping_cache = {}
46+
self.mapping_cache = TTLCache(maxsize=10000, ttl=3600)
4647

4748
######### UTILS
4849
# region utils

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ requests~=2.28.2
88
setuptools~=66.1.1
99
sseclient~=0.0.27
1010
stix2~=3.0.1
11+
cachetools~=5.3.0

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ install_requires =
4242
setuptools~=66.1.1
4343
sseclient~=0.0.27
4444
stix2~=3.0.1
45+
cachetools~=5.3.0
4546

4647
[options.extras_require]
4748
dev =

0 commit comments

Comments
 (0)