def METHOD_NAME(self, q):
    total = IastAgent.objects.filter(q).count()
    max_id = IastAgent.objects.filter(q).values_list("id", flat=True).order_by("-id")[0] if total > 0 else 0
    cache.set(self.cache_key, total, 60 * 60)
    cache.set(self.cache_key_max_id, max_id, 60 * 60)
    return total, max_id