-
-
Notifications
You must be signed in to change notification settings - Fork 453
Memcached ignores custom host/port configurations #675
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
Comments
Hello, nope no idea. It's up to you to find the host & port that allows memcached driver to connect to. Cheers, |
@Geolim4 I did some more tests and found that PHPFastCache appears to be not honoring the host and port details at all. I started a local memcached instance then it worked even after entering several fake host and port details. That said, this issue might not be related to Docker at all but simply due to PHPFastCache ignoring user supplied host and port details. Can you kindly confirm if this is indeed the case? |
Phpfastcache does use Memcached:
Memcacahed is also fully tested: So you've probably misconfigured the driver :/ |
Not sure if it's related but I tried that test file and replaced line 29 and 30 with: 'host' => '123',
'port' => 123, which is an invalid host/port and it passed, is that expected? |
The host and port are the default memcached ones, but if your memcached server does not listen on that host/port combination it's not the Pfc's fault then :) |
You mean to say it can only listen to localhost? |
Anyway, if what you're saying is true, what do you make of my first example where PFC can't connect but using plain PHP's |
What can I say ? The tests passes :/
Have a look at the config file too: And tells me if something can be improved, but actually the tests passes and my local vagrant box is connecting on a custom port too |
I'll see what I can find. I think the custom port works fine but the issue is using a different host ip other than Have you tried using a random fake host ip like |
Can you try with |
You mean in plain PHP memcached? Yes that's what I'm doing in my example, I don't think there's a |
No I mean using phpfastcache config...
…On Sat, Mar 2, 2019, 5:14 AM zkwbbr ***@***.***> wrote:
You mean in plain PHP memcached? Yes that's what I'm doing in my example,
I don't think there's a setHost() method.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#675 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABRTZwQmWhqpWdCZPGKho5chEm6y2_RFks5vSfqSgaJpZM4bOcim>
.
|
How do I do that? This is what I'm using: $cfg = [
'host' => $ip,
'port' => $port
];
$driver = CacheManager::Memcached(new Drivers\Memcached\Config($cfg));
$cache = new Psr16Adapter($driver); |
Are you using an IDE or a text-plain editor ? |
IDE, I don't see |
Sorry I mean |
Wait, can you let me know how to properly use the PSR16 adapter with memcached? I feel like I'm missing something there. Here's what I'm currently doing: $servers = [[
'host' => $ip,
'port' => $port
]];
$conf = new Drivers\Memcached\Config;
$conf->setServers($servers);
$cache = new Psr16Adapter('memcached', $conf);
$cache->set('foo', 'bar');
echo $cache->get('foo'); This returns an error:
|
The memcached backend returned a string which is not expected at all :/ |
Phpfastcache stores values in a certain way and expected to retrieve them in the same way. |
The error happens just right after doing |
Are you sure that you've not set data previously outside of phpfastcache api ? |
I did, I think that solves it. |
It still bugs me why setHost() and setPort does not works on you |
I have to dig it |
Yes, doing this doesn't work:
Also, my original first example post only works if localhost (127.0.0.1) memcached is active, it can't "see" a different IP. |
I think I know why:
I use
|
This can be confirmed by testing that: Replace your old code: $conf = new Drivers\Memcached\Config;
$conf->setHost($ip);
$conf->setPort($port); with that: $conf = new Drivers\Memcached\Config;
$conf->serServers([]);
$conf->setHost($ip);
$conf->setPort($port); Tell me if it's working |
$conf = new Drivers\Memcached\Config;
$conf->setServers([]);
$conf->setHost($ip);
$conf->setPort($port); That works! |
Mhhh okay, got it, I'll push a fix later, my tests are using |
No worries, thank you. |
I'm gonna push a new release by the end of week, thanks ! |
Sorry, I tried the new update, but I'm now facing a new issue.
It wasn't like this before the update, sorry about it :) |
Yeah because these keys are still required, even if you set them to null ;) |
Sorry but I believe they're not required by memcached? To clarify: This works without setting $conf->setHost($ip);
$conf->setPort($port); But this doesn't work (as of 7.0.5): $servers = [[
'host' => $ip,
'port' => $port,
]];
$conf->setServers($servers); |
It's not about Memcached by itself, but about the config validation of PFC. |
Uh oh!
There was an error while loading. Please reload this page.
Configuration
My question
How can I use memcached driver when connecting to a Docker memcached container ?
The following code below doesn't seem to work:
The above code returns:
Fatal error: Uncaught Phpfastcache\Exceptions\PhpfastcacheDriverConnectException: Memcached failed to connect with the following error message: "Memcached seems to not be connected" line 115 in /srv/app/vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Drivers/Memcached/Driver.php
However, when I test the same memcached connection using plain PHP, it works:
Any ideas why?
The text was updated successfully, but these errors were encountered: