mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Add memoize implementation for settings purposes
This commit is contained in:
parent
3a3e552b0a
commit
0c85093937
2 changed files with 19 additions and 3 deletions
|
|
@ -1,9 +1,9 @@
|
|||
import os
|
||||
# from functools import lru_cache
|
||||
|
||||
from pymongo import MongoClient
|
||||
from openpype.api import get_system_settings, get_project_settings
|
||||
from openpype.modules.shotgrid.lib.const import MODULE_NAME
|
||||
from openpype.modules.shotgrid.lib.tools import memoize
|
||||
|
||||
|
||||
def get_project_list():
|
||||
|
|
@ -13,12 +13,12 @@ def get_project_list():
|
|||
return db.list_collection_names()
|
||||
|
||||
|
||||
# @lru_cache(maxsize=64)
|
||||
@memoize
|
||||
def get_shotgrid_project_settings(project):
|
||||
return get_project_settings(project).get(MODULE_NAME, {})
|
||||
|
||||
|
||||
# @lru_cache(maxsize=64)
|
||||
@memoize
|
||||
def get_shotgrid_settings():
|
||||
return get_system_settings().get("modules", {}).get(MODULE_NAME, {})
|
||||
|
||||
|
|
|
|||
16
openpype/modules/shotgrid/lib/tools.py
Normal file
16
openpype/modules/shotgrid/lib/tools.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
from functools import wraps
|
||||
|
||||
|
||||
def memoize(function):
|
||||
memo = {}
|
||||
|
||||
@wraps(function)
|
||||
def wrapper(*args):
|
||||
try:
|
||||
return memo[args]
|
||||
except KeyError:
|
||||
rv = function(*args)
|
||||
memo[args] = rv
|
||||
return rv
|
||||
|
||||
return wrapper
|
||||
Loading…
Add table
Add a link
Reference in a new issue