File indexing completed on 2026-04-10 08:39:06
0001 """
0002 cache specification for JEDI
0003
0004 """
0005
0006
0007 class JediCacheSpec(object):
0008
0009 attributes = (
0010 "main_key",
0011 "sub_key",
0012 "data",
0013 "last_update",
0014 )
0015
0016
0017 def __init__(self):
0018
0019 for attr in self.attributes:
0020 object.__setattr__(self, attr, None)
0021
0022
0023 def valuesMap(self):
0024 ret = {}
0025 for attr in self.attributes:
0026 val = getattr(self, attr)
0027 ret[f":{attr}"] = val
0028 return ret
0029
0030
0031 def pack(self, values):
0032 for i, attr in enumerate(self.attributes):
0033 val = values[i]
0034 object.__setattr__(self, attr, val)
0035
0036
0037 @classmethod
0038 def columnNames(cls, prefix=None):
0039 ret = ""
0040 if prefix is None:
0041 ret = ",".join(cls.attributes)
0042 else:
0043 ret = ",".join([f"{prefix}.{attr}" for attr in cls.attributes])
0044 return ret
0045
0046
0047 @classmethod
0048 def bindValuesExpression(cls):
0049 values_str = ",".join([f":{attr}" for attr in cls.attributes])
0050 ret = f"VALUES({values_str})"
0051 return ret
0052
0053
0054 @classmethod
0055 def bindUpdateChangesExpression(cls):
0056 ret = ",".join(["{0}=:{0}".format(attr) for attr in cls.attributes])
0057 return ret