Memcache data is too large, causing $ mem-> get ($ key) to result in bool (false). could you please kindly advise?

Source: Internet
Author: User
Because memcache data is too large, $ mem-& gt; get ($ key) returns bool (false). could you please kindly advise? thank you for choosing 20000 pieces of data, get the cached content of memcache and display it normally.


However, if you select 25000 data records and obtain the memcache cache content, the result is bool (false );

Simply put, the memcache cache cannot be generated because the search result contains too much content.

Thank you for your advice.


Reply to discussion (solution)

Select 25000 is indeed very large. I think it is better to use memcache as a database. The value of memcache is stored in the memory. if the memory is insufficient, false is returned. this is my understanding. We look forward to seeing how experts can answer this question.

Memcache should automatically replace the old one with the new one.

Code on, no code you say a hammer

Memcache seems crazy.

We recommend that you do not set the memcache size to 1 MB.

You can try Redis

Memcache should automatically replace the old one with the new one.

Code on, no code you say a hammer

// Connection
$ Mem = new Memcache;
$ Mem-> connect ("127.0.0.1", 11211) or die ("cocould not connect ");
Print_r ($ mem-> getStats ());
Echo"
";
$ Q = "select * from uploadfile"; // There are 28000 data records
$ Key = md5 ($ q );

If (! ($ Datas = $ mem-> get ($ key )))
{
Echo "Read datas from MySQL
";
$ Rs = $ db_oa-> Execute ($ q );
While (! $ Rs-> EOF)
{
$ Ss. = $ rs-> f ("fileonsvrname ")."
";
$ Rs-> Movenext ();
}
$ Mem-> set ($ key, $ ss, 0, 20); // The set setting is invalid (problem)
$ Datas = $ mem-> get ($ key );
}
Else
{
Echo "Read datas from memcached
";
}
Var_dump ($ datas ); // the output result is (Array ([pid] => 1612 [uptime] => 21152 [time] => 1366094659 [version] => 1.2.6 [pointer_size] => 32 [curr_items] => 2 [total_items] => 11 [bytes] => 1401127 [curr_connections] => 2 [total_connections] => 39 [connection_structures] => 3 [cmd_get] => 50 [performance_set] => 11 [get_hits] => 33 [get_misses] => 17 [evictions] => 0 [bytes_read] => 14237871 [bytes_written] => 21454105 [limit_maxbytes] = & gt; 67108864 [threads] = & gt; 1)
Read datas from MySQL
Bool (false ))

Is there any answer that can help solve the problem? thank you.

Looking forward to Daniel ......

Looking forward to Daniel ......

We recommend that you do not set the memcache size to 1 MB.

You can try Redis


No construction, yes, certainly cannot exceed 1 M

Save your $ ss and check if it exceeds 1 MB,

I don't know what this means.
If you only want to speed up the search, use the memory table. ENGINE = MEMORY
Speed increases by at least one person's order of magnitude

Retrieving required content from memcache is not an easy task.

Why is it necessary to save the result to memcache ???? What efficiency do you want to improve?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.