33 * @author : Jakiboy
44 * @package : FloatPHP
55 * @subpackage : Helpers Connection Component
6- * @version : 1.3 .x
6+ * @version : 1.4 .x
77 * @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected] > 88 * @link : https://floatphp.com
99 * @license : MIT
2525 */
2626class DataTable extends Orm
2727{
28- use \FloatPHP \Helpers \Framework \tr \TraitCacheable,
29- \FloatPHP \Helpers \Framework \tr \TraitRequestable,
28+ use \FloatPHP \Helpers \Framework \tr \TraitRequestable,
3029 \FloatPHP \Helpers \Framework \tr \TraitDatable,
3130 \FloatPHP \Helpers \Framework \tr \TraitTranslatable,
3231 \FloatPHP \Helpers \Framework \tr \TraitLoggable;
@@ -75,15 +74,6 @@ public function format(array $data = []) : string
7574 return "{ {$ prefix }{$ json }} " ;
7675 }
7776
78- /**
79- * @inheritdoc
80- */
81- public function noCache () : self
82- {
83- $ this ->useCache = false ;
84- return $ this ;
85- }
86-
8777 /**
8878 * Build datatable response.
8979 *
@@ -95,9 +85,6 @@ public function noCache() : self
9585 */
9686 protected function build (?string $ table = null , ?string $ key = null , array $ columns = []) : string
9787 {
98- // Init ORM
99- parent ::__construct ();
100-
10188 // Set table
10289 $ this ->table = $ table ? $ table : (new Catcher ())->key ;
10390 $ this ->key = $ key ?: "{$ this ->table }Id " ;
@@ -369,28 +356,23 @@ protected function getData() : array
369356 // Set filtered data outside cache
370357 $ this ->setSearchCount ();
371358
372- if ( $ this ->useCache ) {
373-
374- $ cache = new Cache ();
375- $ key = $ cache ->getKey ($ this ->table , [
376- 'start ' => $ this ->getStart (),
377- 'length ' => $ this ->getLength (),
378- 'orderby ' => $ this ->getOrderBy (),
379- 'order ' => $ this ->getOrder (),
380- 'search ' => $ this ->getSearch (),
381- 'total ' => $ this ->total ,
382- 'filtered ' => $ this ->filtered
383- ]);
384-
385- $ data = $ cache ->get ($ key , $ status );
386- if ( !$ status ) {
387- $ data = $ this ->prepare ();
388- $ cache ->validate ()->set ($ key , $ data , 0 , $ this ->table );
389- }
390- return $ data ;
391- }
359+ $ cache = new Cache ();
360+ $ key = $ cache ->getKey ($ this ->table , [
361+ 'start ' => $ this ->getStart (),
362+ 'length ' => $ this ->getLength (),
363+ 'orderby ' => $ this ->getOrderBy (),
364+ 'order ' => $ this ->getOrder (),
365+ 'search ' => $ this ->getSearch (),
366+ 'total ' => $ this ->total ,
367+ 'filtered ' => $ this ->filtered
368+ ]);
392369
393- return $ this ->prepare ();
370+ $ data = $ cache ->get ($ key , $ status );
371+ if ( !$ status ) {
372+ $ data = $ this ->prepare ();
373+ $ cache ->validate ()->set ($ key , $ data , 0 , $ this ->table );
374+ }
375+ return $ data ;
394376 }
395377
396378 /**
0 commit comments