#
# Sub Sheets for WWS
# Created by @dansage
#

class ModelCache:

  def __init__(self):
    # create the caches
    self.classes = {}
    self.students = {}
    self.teachers = {}

  def store_class(self, class_):
    # check if the class is already cached
    if not class_.build_key() in self.classes:
      # cache the instance provided
      self.classes[class_.build_key()] = class_

    # return the instance present in the cache
    return self.classes[class_.build_key()]

  def store_student(self, student):
    # check if the student is already cached
    if not student.id in self.students:
      # cache the instance provided
      self.students[student.id] = student

    # return the instance present in the cache
    return self.students[student.id]

  def store_teacher(self, teacher):
    # check if the teacher is already cached
    if not teacher.id in self.teachers:
      # cache the instance provided
      self.teachers[teacher.id] = teacher

    # return the instance present in the cache
    return self.teachers[teacher.id]

#
# Sub Sheets for WWS
# Created by @dansage
#

class ModelCache:

  def __init__(self):
    # create the caches
    self.classes = {}
    self.students = {}
    self.teachers = {}

  def store_class(self, class_):
    # check if the class is already cached
    if not class_.build_key() in self.classes:
      # cache the instance provided
      self.classes[class_.build_key()] = class_

    # return the instance present in the cache
    return self.classes[class_.build_key()]

  def store_student(self, student):
    # check if the student is already cached
    if not student.id in self.students:
      # cache the instance provided
      self.students[student.id] = student

    # return the instance present in the cache
    return self.students[student.id]

  def store_teacher(self, teacher):
    # check if the teacher is already cached
    if not teacher.id in self.teachers:
      # cache the instance provided
      self.teachers[teacher.id] = teacher

    # return the instance present in the cache
    return self.teachers[teacher.id]

# # Sub Sheets for WWS # Created by @dansage # # create the caches # check if the class is already cached # cache the instance provided # return the instance present in the cache # check if the student is already cached # cache the instance provided # return the instance present in the cache # check if the teacher is already cached # cache the instance provided # return the instance present in the cache