PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, November 13, 2022

[FIXED] what is the server_key in php memcached?

 November 13, 2022     memcached, php     No comments   

Issue

php document discription and example:

public array Memcached::getServerByKey ( string $server_key )

<?php 
$m = new Memcached();
$m->addServer('mem1.domain.com', 11211, 33);
$m->addServer('mem2.domain.com', 11211, 67);
?>

I cannot find the server_key param. where is the server_key?

how to use ***bykey functions?

Memcached::addByKey()
Memcached::deleteByKey()
Memcached::getServerByKey()
...

Solution

From http://php.net/manual/en/memcached.getserverbykey.php:

server_key

The key identifying the server to store the value on or retrieve it from. Instead of hashing on the actual key for the item, we hash on the server key when deciding which memcached server to talk to. This allows related items to be grouped together on a single server for efficiency with multi operations.

Normally, the memcached server is chosen based on the key you're storing (e.g. Memcached::add("key", "value") chooses which server to use based on "key"). By specifying a server key, you can change which server is chosen.

So it's something you provide if you want to group values by some means other than the key you're storing or looking up.



Answered By - user94559
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing