Skip to content

Commit d9d540c

Browse files
chaenfstagni
authored andcommitted
feat (TS Utilities): cache isSameSEInList
1 parent 7a9be13 commit d9d540c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/DIRAC/TransformationSystem/Client/Utilities.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import ast
1010
import random
1111

12+
from cachetools import LRUCache, cached
13+
from cachetools.keys import hashkey
1214
from DIRAC import S_OK, S_ERROR, gLogger
1315

1416
from DIRAC.Core.Utilities.List import breakListIntoChunks
@@ -400,6 +402,10 @@ def isSameSE(self, se1, se2):
400402

401403
return StorageElement(se1).isSameSE(StorageElement(se2))
402404

405+
@cached(
406+
LRUCache(maxsize=1024),
407+
key=lambda _, a, b: hashkey(a, *sorted(b)),
408+
)
403409
def isSameSEInList(self, se1, seList):
404410
"""Check if an SE is the same as any in a list"""
405411
if se1 in seList:

0 commit comments

Comments
 (0)