Welcome Guest, Not a member yet? Register   Sign In
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, 11:50 AM)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, 08:42 AM)php_rocs Wrote:
(05-05-2018, 11:50 AM)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, 12:58 AM)omid_student Wrote:
(05-11-2018, 08:42 AM)php_rocs Wrote:
(05-05-2018, 11:50 AM)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, 07: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, 01: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

(This post was last modified: 05-17-2018, 11:04 AM by php_rocs.)

(05-16-2018, 11:25 PM)omid_student Wrote:
(05-16-2018, 01: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

(This post was last modified: 05-17-2018, 11:50 AM by omid_student.)

(05-17-2018, 11:02 AM)php_rocs Wrote:
(05-16-2018, 11:25 PM)omid_student Wrote:
(05-16-2018, 01: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




Theme © iAndrew 2016 - Forum software by © MyBB