Hello fellow phalconeers
Everytime the function 'getBookings' is called and it tries to save the write to the file it throws the error: Cache file ../cache/easytablebooking/bookings_all-10 could not be written
the folder ../cache/easytablebooking/ has the permissions chmod -R 775 and owner the owner is www-data:www-data
The modelsCache service who caches the models works fine, but this class doesn't.
It does create the file in the correct directory, but cannot write to it.
Do you guys have an idea?
OS: Ubuntu 14.04 PHP-V: 5.6.20
<?php
namespace EasyTableBooking\Cache;
use Phalcon\Cache\Backend\File as File; use Phalcon\Cache\Frontend\Output as FrontOutput; use EasyTableBooking\Bookings\EasyTableBookingBookings; use EasyTableBooking\Authorize\EasyTableBookingAuthorization;
class EasyTableBookingCache {
/**
* Cache object
* @var File
*/
protected $EasyTableBookingCache;
/**
* @var EasyTableBookingBookings
*/
protected $EasyTableBookingBookings;
/**
* Unique restaurant identifier
* @var integer
*/
protected $resellerChainID;
/**
* Unique cache suffix
* @var string
*/
private $suffix;
public function __construct($resellerChainID) {
$EasyTableBookingAuthorization = new EasyTableBookingAuthorization($resellerChainID);
$this->EasyTableBookingBookings = new EasyTableBookingBookings($EasyTableBookingAuthorization);
$this->suffix = $resellerChainID;
$frontCache = new FrontOutput(
array(
'lifetime' => 30
)
);
$this->EasyTableBookingCache = new File(
$frontCache,
array(
'cacheDir' => '/cache/easytablebooking/'
)
);
}
public function getBookings($refresh = false) {
$bookings = $this->EasyTableBookingCache->get('bookings_all-' . $this->suffix, 15);
if($bookings !== null && $refresh === false):
return $bookings;
else:
$bookings = $this->EasyTableBookingBookings->getBookings();
if($bookings):
$this->saveBookings($bookings);
return $bookings;
else:
return false;
endif;
endif;
}
public function saveBookings($bookings) {
$save = $this->EasyTableBookingCache->save('bookings_all-' . $this->suffix, $bookings, 15);
if($save):
return true;
else:
return false;
endif;
}
}