21303 Posts in 5736 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 589 Views |
-
Clearing cached data for specific DataObjectSet

15 March 2011 at 9:27am
Hi, So I have an application that displays a list of bookings. These bookings are called from an API and added to a DataObjectSet before being passed to the HTML. The bookings are only displayed if their status is "active".
The DataObjectSet looks like this:
$Res = new DataObjectSet();
foreach($this->Reservations as $current) {
if(!empty($current->Status)) {
if($current->Status == "Active") {
// To retrieve the date in a format that Silverstripe
// will be able to play with, we need to convert it to a date object.
$Date = new Date('Date');
$Date->setValue((string)$current->DateMade);
$dateMade = $Date->Format('D, j M Y');
// Put info from RSS into an Array, then push into $result
$Res->push(new ArrayData(array(
'ItineraryRef' => (int)$current->ItineraryRef,
'Type' => (string)$current->Type,
'DateMade' => (string)$dateMade,
'DateCreated' => (string)$current->DateMade,
'URLDate' => (string)$current->DateMade,
'PaxCount' => (int)$current->PaxCount,
'Description' => (string)$current->Description,
'Status' => (string)$current->Status,
'DateAccessed' => $Date,
)));
$i++;
}
}
Next to each booking is a link which will cancel the booking, again this is done by calling another API that immediately sets the status of the booking to "CANCELLED" so that they do not appear in the list.I want cancelled bookings to disappear from the list the next time the page refreshes but even though the bookings definitely get cancelled in the back-end; on the front-end, the cancelled bookings always remain 'active' until the user logs off and logs back in again.
I think the problem is that Silverstripe is not calling new data from the API after the page refreshes, it retrieves old data from the DataObjectSet and the information in the DataObjectSet remains intact until the user logs off and the session is destroyed.
So my question is, how do you tell silverstripe to delete any cached information for a specific DataObjectSet or to not cache DataObjects at all?
I tried DataObject::destroy() and $Res->destroy() but that kills the users session too
Any alternative ideas are welcome too. Thanks
-
Re: Clearing cached data for specific DataObjectSet

16 March 2011 at 8:57am
So...no response because there is no answer? Or because the answer is obvious? Which one?
-
Re: Clearing cached data for specific DataObjectSet

16 March 2011 at 9:54am Last edited: 16 March 2011 9:55am
There is, for instance, the DataObject->flushCache() method. Check the DataObject API here:
http://api.silverstripe.org/2.4/sapphire/model/DataObject.html#methodflushCache
-
Re: Clearing cached data for specific DataObjectSet

16 March 2011 at 11:20am
Unfortunately that function does not exist for DataObjectSets, unless there is a way to hack that same functionality in there.
I also tried DataObject::FlushCache(true) but that appeared to have no influence. The list still reloads with deleted bookings as if nothing happened
| 589 Views | ||
|
Page:
1
|
Go to Top |
