Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00020 final class CustomDataScopedWorker extends CacheDaoWorker
00021 {
00022 public function __construct($dao)
00023 {
00024 $this->dao = $dao;
00025
00026 $this->className = $dao->getObjectName();
00027
00028 if (($cache = Cache::me()) instanceof WatermarkedPeer)
00029 $this->watermark =
00030 $cache->mark($this->className)->getActualWatermark();
00031 }
00032
00033 public function cacheData(
00034 $key,
00035 $data,
00036 $expires = Cache::EXPIRES_FOREVER
00037 )
00038 {
00039 Cache::me()->mark($this->className)->
00040 add(
00041 $this->makeDataKey($key, self::SUFFIX_QUERY),
00042 $data,
00043 $expires
00044 );
00045
00046 return $data;
00047 }
00048
00049 public function getCachedData($key)
00050 {
00051 return
00052 Cache::me()->mark($this->className)->
00053 get($this->makeDataKey($key, self::SUFFIX_QUERY));
00054 }
00055
00056 private function makeDataKey($key, $suffix)
00057 {
00058 return
00059 $this->className
00060 .$suffix
00061 .$key
00062 .$this->watermark
00063 .$this->getLayerId();
00064 }
00065 }
00066 ?>