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
#963 MemcachedStorage Notice if deamon is not running, incl. test #980
base: master
Are you sure you want to change the base?
Conversation
Is it necessary to fix it in this way? This is an advantage of Memcache to add server which may be offline. Other servers may be online and this one just loose priority. I hope, better solution is to somehow provide access to 8th |
|
||
try { | ||
$cache = new Cache(new MemcachedStorage('localhost', 11666)); // assume that on this port by default is not running | ||
Assert::fail('Expected exception'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an Assert::exception()
for this purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. That's exactly what I was looking for. This code I copied from other tests. Btw. Is there any help for Nette/Tester?
I cant imagine that someone uses memcache offline. What's the point? But, if so, can wrap each call addServer in try/catch block and then work with it. |
|
The point is that the exception is better than hidden notice. Exception can be handled explicitly, notice no. |
I can't be sure that pull out failure_callback is the solution. you got it checked? |
My point is that offline state is a normal cache state, not a fault. Cache is not permanent data storage. With your patch... what happend when server is online when |
I checked that "offline message" notice is catched by callback. |
Both method return NULL or FALSE if server failed. |
I noticed that method |
Yes, NULL or FALSE is returned without notice, but only when server is offline during |
Okey. I got it. Options:
|
And I fix |
@patriksima I am not using memcached and I don't know if this pull is good to merge. This #980 (comment) makes sense to me. |
@dg I wrote options. Which way should I go? |
I have done small investigation... One big advantage of Memcache class is, that can be used with offline servers. Actually it works without added servers. Yes, it emits notices/warnings but works. Adding server even if is offline is important. Memcache do statistics and prioritize servers. Exception cannot be throws due to BC (application stops working with offline server, moreover, addServer is in constructor). Shut-up operator in Pass failure callback for Better solution is install error handler before every memcache method calling and catch notices (see d59555a). I was afraid about performace, but on my laptop: for ($i = 0; $i < 100000; $i++) { # 20ms
}
for ($i = 0; $i < 100000; $i++) { # 380ms
set_error_handler(function() { restore_error_handler(); });
restore_error_handler();
} Question is, if handle only notices or all errors (http://svn.php.net/viewvc/pecl/memcache/trunk/memcache.c?view=markup). |
991ba1a
to
e23de7a
Compare
489cca2
to
0b969cd
Compare
09a7d92
to
b9698a8
Compare
5a8c108
to
3aa3147
Compare
5feee0e
to
3fc1e40
Compare
688f189
to
1bc9d13
Compare
7215ae6
to
71b2047
Compare
No description provided.