You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

34 lines
895 B

  1. <?php
  2. //领域层主要是关注复杂业务的处理,以及缓存的处理、耗时操作后台异步处理等,并调用Model持久层获取需要的数据。因此,是Api与Model层之间的桥梁。
  3. class Domain_User {
  4. public function getBaseInfo($userId) {
  5. $rs = array();
  6. $userId = intval($userId);
  7. if ($userId <= 0) {
  8. return $rs;
  9. }
  10. // 版本1:简单的获取
  11. $model = new Model_User();
  12. $rs = $model->getByUserId($userId);
  13. // 版本2:使用单点缓存/多级缓存 (应该移至Model层中)
  14. /**
  15. $model = new Model_User();
  16. $rs = $model->getByUserIdWithCache($userId);
  17. */
  18. // 版本3:缓存 + 代理
  19. /**
  20. $query = new PhalApi_ModelQuery();
  21. $query->id = $userId;
  22. $modelProxy = new ModelProxy_UserBaseInfo();
  23. $rs = $modelProxy->getData($query);
  24. */
  25. return $rs;
  26. }
  27. }