Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 911859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:16:56+00:00 2026-05-15T17:16:56+00:00

I use Php memcache on PHP Version 5.2.4-2ubuntu5.10 Below you can find the info

  • 0

I use Php memcache on PHP Version 5.2.4-2ubuntu5.10 Below you can find the info from phpinfo.

When I use key larger than 250 characters memcache returns true on $memcache->set and false on $memcache->get .

Any idea how to set it to work normally (truncate key at 250 chars)?

If not – what would be the easiest way to override memcache across all my code to log the calls and know where I should change the key?
Thanks

memcache support    enabled
Active persistent connections   0
Revision    $Revision: 1.86 $

Directive   Local Value Master Value
memcache.allow_failover 1   1
memcache.chunk_size 8192    8192
memcache.default_port   11211   11211
memcache.hash_function  crc32   crc32
memcache.hash_strategy  standard    standard
memcache.max_failover_attempts  20  20
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:16:57+00:00Added an answer on May 15, 2026 at 5:16 pm

    The maximum size is indeed 250 (see here).

    You shouldn’t truncate the keys, as it can map keys that were different to the same value (same for md5, though it’s highly unlikely to happen by accident).

    If you want to detect the cases where it’s happening and since you’re using the OOP interface, you can decorate the memcache object, overriding set or get (or both) to throw an exception or an error when it finds a long key.

    With only inheritance (no decoration), you can do

    class MemcacheEx extends Memcache {
        public function set($key, $var, int $flag=0, $expire=0) {
            //do something with $key
            parent::set($key, $var, $flag, $expire);
        }
    
        //... similar for get
    }
    $memcache = new MemcacheEx(); //instead of new Memcache()
    //...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use php to display a table of data drawn from my mysql database.
I can't use PHP in my HTML pages. For example, index.html . I've tried
Is there anyway to use / install the memcache extension for PHP on Heroku?
Use Memcache php class to interact with the memcached. At the beginning all works
Everybody knows there are two extensions for memcache on PHP: memcache memcached You can
I'm trying to use memcache to handle session in PHP. I still want to
I just installed PHP on Ubuntu Natty from source. I'm trying to use PECL
Use PHP and Mysql. Fields in my table (product) are id , full_price ,
I use php with ajax. <?php /* * Suppose, user has entered both correct
I am trying to use PHP to fire hits at Google to track newsletter

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.