• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cache database

#1
Hi
I use $this->db->cache_on for cache my query
But when i execute query,it dont save query sometimes
What is problem?
Reply

#2
(05-05-2018, 12:50 PM)omid_student Wrote: Hi
I use $this->db->cache_on for cache my query
But when i execute query,it dont save query sometimes
What is problem?

Is it possible to see the code around this statement?  It would allow us to better assess the issue or problem.
Reply

#3
(05-11-2018, 09:42 AM)php_rocs Wrote:
(05-05-2018, 12:50 PM)omid_student Wrote: Hi
I use $this->db->cache_on for cache my query
But when i execute query,it dont save query sometimes
What is problem?

Is it possible to see the code around this statement?  It would allow us to better assess the issue or problem.
Yes
Here:
PHP Code:
        public function delete_cache_file($query,$segment_one ''$segment_two '')
        {
            if (
$segment_one === '')
            {
                
$segment_one  = ($this->uri->segment(1) == FALSE) ? 'default' $this->uri->segment(1);
            }

            if (
$segment_two === '')
            {
                
$segment_two = ($this->uri->segment(2) == FALSE) ? 'index' $this->uri->segment(2);
            }

            
$file_path $this->db->cachedir.$segment_one.'+'.$segment_two.'/'.md5($query);
            @
unlink($file_path);
        } 
Reply

#4
(05-12-2018, 01:58 AM)omid_student Wrote:
(05-11-2018, 09:42 AM)php_rocs Wrote:
(05-05-2018, 12:50 PM)omid_student Wrote: Hi
I use $this->db->cache_on for cache my query
But when i execute query,it dont save query sometimes
What is problem?

Is it possible to see the code around this statement?  It would allow us to better assess the issue or problem.
Yes
Here:
PHP Code:
public function delete_cache_file($query,$segment_one ''$segment_two '')
 {
 if (
$segment_one === '')
 {
 
$segment_one  = ($this->uri->segment(1) == FALSE) ? 'default' $this->uri->segment(1);
 }

 if (
$segment_two === '')
 {
 
$segment_two = ($this->uri->segment(2) == FALSE) ? 'index' $this->uri->segment(2);
 }

 
$file_path $this->db->cachedir.$segment_one.'+'.$segment_two.'/'.md5($query);
 @
unlink($file_path);
 } 

Actually i get query string and md5 it and combine with segments and delete file
Reply

#5
@omid_student,

Also, have you checked the CI/Apache log to see if there were error messages? I also noticed that you are suppressing errors "@unlink". Maybe for testing purposes you should not suppress errors.
Reply

#6
(05-16-2018, 08:35 AM)php_rocs Wrote: @omid_student,

Also, have you checked the CI/Apache log to see if there were error messages?  I also noticed that you are suppressing errors "@unlink".  Maybe for testing purposes you should not suppress errors.

Why log?
My code have no error
Reply

#7
@omid_student,
Maybe it threw a error/warning when it tried to delete the file but was unable to.
Reply

#8
(05-16-2018, 02:12 PM)php_rocs Wrote: @omid_student,
Maybe it threw a error/warning when it tried to delete the file but was unable to.

I can check file existing or not
Or add @ before unlink Blush
Reply

#9
(05-17-2018, 12:25 AM)omid_student Wrote:
(05-16-2018, 02:12 PM)php_rocs Wrote: @omid_student,
Maybe it threw a error/warning when it tried to delete the file but was unable to.

I can check file existing or not
Or add @ before unlink  Blush

I would remove @ before unlink. I try not to suppress errors. This way the errors should be logged.
Reply

#10
(05-17-2018, 12:02 PM)php_rocs Wrote:
(05-17-2018, 12:25 AM)omid_student Wrote:
(05-16-2018, 02:12 PM)php_rocs Wrote: @omid_student,
Maybe it threw a error/warning when it tried to delete the file but was unable to.

I can check file existing or not
Or add @ before unlink  Blush

I would remove @ before unlink.  I try not to suppress errors.  This way the errors should be logged.

Yes you are right
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.