我的 Web 应用程序中有各种自定义数据类型来映射数据库中的一些数据。
就像是:
Person
Id
Name
Surname
我需要在我的大多数应用程序页面中列出人员列表
我正在考虑创建一个 getter 属性,它从数据库中获取人员列表并以这种方式存储到缓存中,我不必每次都调用数据库
类似的东西(伪代码)
public List<Person> Persons
{
get { return if cache != null return List of Persons from cache else get from the database;}
}
我应该把这个吸气剂放在哪里?在我的 Person 类定义或我的基本页面中(所有其他页面继承的页面)
谢谢