MCPcopy
hub / github.com/TaskingAI/TaskingAI / set

Method set

backend/tkhelper/models/redis.py:58–73  ·  view source on GitHub ↗
(self, entity: ModelEntity)

Source from the content-addressed store, hash-verified

56 return None
57
58 async def set(self, entity: ModelEntity):
59 if not self.redis_conn:
60 return
61
62 # Extract primary key fields and their values from entity
63 pk_fields = self.entity_class.primary_key_fields()
64 pk_values = {field: getattr(entity, field) for field in pk_fields}
65
66 # Generate the Redis key using primary key values
67 key = self.__key(**pk_values, postfix=self.redis_key_postfix)
68
69 # Convert entity to a dictionary suitable for Redis (assuming such a method exists)
70 entity_dict = entity.to_redis_dict() # This method depends on the actual implementation of ModelEntity
71
72 # Set the object in Redis with the generated key and expiration
73 await self.redis_conn.set_object(key, entity_dict, self.expire)
74
75 async def pop(self, entity: ModelEntity):
76 if not self.redis_conn:

Callers 5

set_intMethod · 0.80
set_objectMethod · 0.80
set_stringMethod · 0.80
register_adminFunction · 0.80
refresh_admin_tokenFunction · 0.80

Calls 4

__keyMethod · 0.95
to_redis_dictMethod · 0.80
set_objectMethod · 0.80
primary_key_fieldsMethod · 0.45

Tested by

no test coverage detected