문제

I'm using redis with php (predis at http://github.com/nrk/predis/) and am experiencing frequent timeout. The stack trace shows:

[04-Apr-2010 03:39:50] PHP Fatal error:  Uncaught exception 'Predis_ClientException' with message 'Connection timed out' in redis.php:697
Stack trace:
#0 redis.php(757): Predis_Connection->connect()
#1 redis.php(729): Predis_Connection->getSocket()
#2 redis.php(825): Predis_Connection->writeCommand(Object(Predis_Commands_ListRange))
#3 redis.php(165): Predis_ConnectionCluster->writeCommand(Object(Predis_Commands_ListRange))
#4 redis.php(173): Predis_Client->executeCommandInternal(Object(Predis_ConnectionCluster), Object(Predis_Commands_ListRange))
#5 redis.php(157): Predis_Client->executeCommand(Object(Predis_Commands_ListRange))
#6 [internal function]: Predis_Client->__call('lrange', Array)

This happens consistently and I have no idea why. Anyone has any idea?

도움이 되었습니까?

해결책

I think this is because of idle connections are getting closed by default by Redis.

redis.conf

# Close the connection after a client is idle for N seconds (0 to disable)
timeout 0

다른 팁

형식 문자열은 에서 다르게 작동합니다.

NSString *query = [NSString stringWithFormat:@"author == %@", author] // (1)
.

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"author == %@", author]
.

특히 자리 표시 자 "% @"및 "% k"는 다른 의미를 가지고 있습니다.

(1)은 형식의 문자열 을 생성합니다.

"author == <textual description of author object>"
. 에서 사용할 수없는

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%@", query];
.

문자열로 조건을 사전 포맷 할 수는 없습니다.문제를 입증하는 또 다른 예 :

[NSPredicate predicateWithFormat:@"author == nil"]
.

작동하지만

[NSPredicate predicateWithFormat:"%@", @"author == nil"]
.

가 아닙니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top