Bobcares

Memcached key length limit – Top factors to consider

by | Mar 10, 2020

Looking for factors affecting the Memcached key length limit? Let’s have a closer look.

The maximum length of the key in Memcached has a restriction of 250 bytes.

At Bobcares, we get many queries on Memcached key limits, as a part of our Server Management Services.

Today, our Support Engineers will discuss major limits on Memcached keys.

 

A quick look on Memcached

Memcached is an open-source memory caching system. We use it to speed up dynamic web applications by reducing the database load. That is Memcached loads data from the cache to speed up websites.

The Memcached server is a big hash table suitable for websites with high database load. A hash table is a collection that stores key-value items.

One way to connect to the Memcached server is by using the telnet command. And the command usage is,

telnet <HOST> <PORT>

This connects the server to the Memcached server where we can store and retrieve data.

In Memcached, we can store a key and its corresponding value. We can also provide other details like the expiration time of the key, number of values, and a flag. But Memcached has some limitations on keys and values.

Our Support Engineers will provide a quick guide on them.

 

Limits on a Memcached key

Users use Memcached to store different keys and values. The major restriction in Memcached are:

 

1. Key length limit

The maximum length of the key string must be 250 bytes. And Memcached will not accept a key length more than that.

But for a customer storing URL as the key and string with a relevant keyword as the value, the size of the key is a limitation. Because URLs can have a length of more than 250 bytes.

Here increasing the value of the parameter KEY_MAX_LENGTH in the source code will not increase the limit.

 

2. Syntax restrictions

Similarly, the key name has some character restrictions. That is whitespaces and control characters in the key name throws an error in a line format.

The error appeared due to whitespace in the key name is,

Memcached key length limit.

 

3. Key expiration time

Another major limitation of the Memcached key is its expiration time. The maximum expiration time for a key is 30 days nevertheless it is set to zero.

That is the key will be automatically expired after the expiration time. So it will not be available afterward.

The expiration time also has another side, that is, the key will be expired only after the expiration time. So when a user updates the website, the older keys persist. To avoid that, the user should manually remove the keys.

 

4. Size of the value

In Memcached, there is a size limit for the item. The default value is 1 MB. To change this, we can edit the /etc/init.d/memcached file and add the parameter as

MAXITEMSIZE=<new_limit>

If a user adds a key without considering the limits, it ends up in the error ‘CLIENT_ERROR bad command line format’.

 

[Still, have any queries on Memcached keys? – We can help you.]

 

Conclusion

In short, the Memcached key length limit is 250 bytes. The key name in the Memcached has other limitations in size, syntax, expiration time, etc. Today, our Support Engineers provided some essentials details on this.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF