Exemplo n.º 1
0
 /**
  * Tests if the Time package works correctly.
  */
 public function testGetTTL()
 {
     $from = new DateTime("2015-05-27 22:30:15.638276");
     $until = new DateTime("2015-05-27 22:31:15.889342");
     // Checks if the unitary argument's functionality works fine.
     $this->assertEquals(3600, Time::getTTL(60));
     // Checks if the binary argument's functionality works fine.
     $this->assertEquals(60, Time::getTTL($until, Carbon::instance($from)));
     // Checks if the expected Exception will be thrown.
     $this->setExpectedException(Exception::class);
     Time::getTTL($now, Carbon::instance($expire));
 }
 /**
  * Prepares data to be sent to the cache server.
  *
  * @oaram mixed $data    data to be serialized.
  * @oaram int   $minutes expiration duration in minutes.
  * @param array|string   serialized data.
  */
 public function serialize($data, $minutes = null)
 {
     $ttl = is_null($minutes) ? null : Time::getTTL($minutes);
     return VolatileRecord::marshalize(['data' => $this->coder->encode($data), 'ttl' => $ttl]);
 }