Exemplo n.º 1
0
 /**
  * Writes the cache object to the cache
  * @param zibo\library\cache\CacheObject $object
  * @return null
  */
 public function writeToCache(CacheObject $object)
 {
     $type = $object->getType();
     $id = $object->getId();
     $this->readType($type);
     if (!isset($this->cache[$type])) {
         $this->cache[$type] = array();
     }
     $this->cache[$type][$id] = $object;
 }
Exemplo n.º 2
0
 /**
  * Writes the cache object to the cache
  * @param zibo\library\cache\CacheObject $object
  * @return null
  */
 public function writeToCache(CacheObject $object)
 {
     $type = $object->getType();
     $id = $object->getId();
     $this->readType($type);
     if (!array_key_exists($type, $this->cache)) {
         $this->cache[$type] = array();
     }
     $this->cache[$type][$id] = $object;
 }
Exemplo n.º 3
0
 /**
  * Writes a cache object to file
  * @param zibo\library\cache\CacheObject $object Cache object to write to the data source
  * @return null
  */
 public function writeToCache(CacheObject $object)
 {
     $cacheFile = $this->getCacheFile($object->getType(), $object->getId());
     $cacheDirectory = $cacheFile->getParent();
     $cacheDirectory->create();
     $serializedValue = serialize($object);
     if ($this->useLock) {
         $cacheFile->lock();
         $cacheFile->write($serializedValue);
         $cacheFile->unlock();
     } else {
         $cacheFile->write($serializedValue);
     }
 }
Exemplo n.º 4
0
 public function testConstruct()
 {
     $time = time();
     $timesAccessed = 0;
     $type = 'type';
     $id = 'id';
     $data = 'value';
     $cache = new CacheObject($type, $id, $data);
     $this->assertEquals($type, $cache->getType());
     $this->assertEquals($id, $cache->getId());
     $this->assertEquals($data, $cache->getData());
     $this->assertEquals($timesAccessed, $cache->getTimesAccessed());
     $this->assertEquals($time, $cache->getCreationDate());
     $this->assertEquals($time, $cache->getLastAccessDate());
 }