Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove weight in mm #63

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ jobs:
image: redis
ports:
- 6379:6379

memcached:
image: memcached:alpine3.20
ports:
- "11211:11211"
steps:
- uses: actions/checkout@v2
- name: Setup PHP
Expand Down
26 changes: 26 additions & 0 deletions lib/Pinpoint/Plugins/SysV2/_memcached/Mem_Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Pinpoint\Plugins\SysV2\_memcached;

use Pinpoint\test\TraceTest;

use Memcached;

// vendor/bin/phpunit --configuration PHPUnit_aop_libraries.xml --testsuit pinpoint --testdox --filter Mem_Test
class Mem_Test extends TraceTest
{

public function test_mem_flow()
{
$this->assertTrue(extension_loaded('memcached'));
$mc = new Memcached();
$mc->addServer("localhost", 11211);
$mc->set('key', "abc");
$this->assertTrue($mc->get('key') == 'abc'); // boolean false
var_dump($mc->getResultCode()); // int 0 which is Memcached::RES_SUCCESS
var_dump($mc->add("test_add", 234)); // int 0 which is Memcached::RES_SUCCESS
// var_dump($Memcached->appendByKey("xxx", "test_add", 234)); // int 0 which is Memcached::RES_SUCCESS
var_dump($mc->delete("test_add")); // int 0 which is Memcached::RES_SUCCESS
var_dump($mc->deleteMulti(["test_add", "a", "b", "c"])); // int 0 which is Memcached::RES_SUCCESS
}
}
8 changes: 4 additions & 4 deletions lib/Pinpoint/Plugins/SysV2/_memcached/memcached.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@

use Memcached;

function format_host(Memcached $Memcached): string
function format_host(Memcached $memcached): string
{
$servers = $Memcached->getServerList();
$servers = $memcached->getServerList();
$ret = "";
foreach ($servers as $ser) {
$host = $ser['host'];
$port = $ser['port'];
$weight = $ser['weight'];
$ret .= "memcached(host=$host,port=$port,weight=$weight)";
// removed weight
$ret .= "memcached(host=$host,port=$port)";
}
return $ret;
}
Expand Down
4 changes: 3 additions & 1 deletion lib/Pinpoint/test/TraceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public function checkKeys(array $keys): bool
{
$message = static::$logger_->message_;
foreach ($keys as $key => $time) {
$this->assertEquals(substr_count($message, $key), $time);
$real = substr_count($message, $key);
$target = $time;
$this->assertEquals($real, $target, "key=$key,real=$real, target=$target {$message}");
}
return True;
}
Expand Down
Loading