def save(self): data = {'uuid': self.uuid} for attr_name in self.stored_attrs: data[attr_name] = self.value_of(attr_name) ActiveRedis.connexion().hmset(self.redis_namespace_with_uuid(data['uuid']), data) return data['uuid']
def all_redis_keys(cls): return ActiveRedis.connexion().keys('{}:*'.format(cls.redis_namespace()))
def delete_all(cls): for key in cls.all_redis_keys(): ActiveRedis.connexion().delete(key) return True
def delete(self): return ActiveRedis.connexion().delete( self.redis_namespace_with_uuid(self.uuid))
def update_attr(self, attr_name, value): return ActiveRedis.connexion().hset( self.redis_namespace_with_uuid(self.uuid), attr_name, value)
def find_by_redis_key(cls, redis_key): return cls(**ActiveRedis.connexion().hgetall(redis_key))