I used laravel4framework for development. I want to switch the cacheserver from memcache to redis, and set the driver in configcache. php to redis. However, an error is returned when cache: get () is called. The error message is {code ...} but access to redis-server from redis-cli is OK... I used laravel 4 framework for Development. I want to switch the cache server from memcache to redis, in config/cache. set the driver of php to redis. However, an error is reported when cache: get () is called. The error message is as follows:
[2014-10-21 18:47:44] production.ERROR: exception 'Predis\Connection\ConnectionException' with message 'Error while reading line from the server [tcp://127.0.0.1:6379]' in /home/nginx/mono/vendor/predis/predis/lib/Predis/Connection/AbstractConnection.php:141
However, access to redis-server from redis-cli is OK, and it is okay to test redis separately in phpunit. However, there is a problem in using Route directly.
Route: get ('/test', function () {Cache: put ('name', 'taylor', 60); // error! $ Name = Cache: get ('name'); echo $ name ;});
Who can explain the problem?
Supplement: refresh multiple times/test, several times normal.
Reply content:
I used laravel 4 framework for Development. I want to switch the cache server from memcache to redis, and set the driver in config/cache. php to redis. However, an error is reported when cache: get () is called. The error message is as follows:
[2014-10-21 18:47:44] production.ERROR: exception 'Predis\Connection\ConnectionException' with message 'Error while reading line from the server [tcp://127.0.0.1:6379]' in /home/nginx/mono/vendor/predis/predis/lib/Predis/Connection/AbstractConnection.php:141
However, access to redis-server from redis-cli is OK, and it is okay to test redis separately in phpunit. However, there is a problem in using Route directly.
Route: get ('/test', function () {Cache: put ('name', 'taylor', 60); // error! $ Name = Cache: get ('name'); echo $ name ;});
Who can explain the problem?
Supplement: refresh multiple times/test, several times normal.
StreamConnection Class of Predis
/*** Initializes a TCP stream resource. ** @ param ConnectionParametersInterface $ parameters Parameters used to initialize the connection. * @ return resource */protected function tcpStreamInitializer (ConnectionParametersInterface $ parameters) {$ uri = "tcp: // {$ parameters-> host }:{ $ parameters-> port }"; $ flags = STREAM_CLIENT_CONNECT; if (isset ($ parameters-> async_connect) & $ parameters-> async_connect) {$ Flags | = STREAM_CLIENT_ASYNC_CONNECT;} if (isset ($ parameters-> persistent) & $ parameters-> persistent) {$ flags | = STREAM_CLIENT_PERSISTENT; $ uri. = strpos ($ path = $ parameters-> path, '/') = 0? $ Path: "/$ path";} $ resource = @ stream_socket_client ($ uri, $ errno, $ errstr, $ parameters-> timeout, $ flags); if (! $ Resource) {$ this-> onConnectionError (trim ($ errstr), $ errno);} // here, you need to set a timeout value for the read stream, otherwise, an error is reported when the stream data is read. // you can directly set read_write_timeout to 0 to solve the problem. If (isset ($ parameters-> read_write_timeout) {$ rwtimeout = $ parameters-> read_write_timeout; $ rwtimeout = $ rwtimeout> 0? $ Rwtimeout:-1; $ timeoutSeconds = floor ($ rwtimeout); $ timeoutUSeconds = ($ rwtimeout-$ timeoutSeconds) * 1000000; stream_set_timeout ($ resource, $ timeoutSeconds, $ timeoutUSeconds);} if (isset ($ parameters-> tcp_nodelay) & function_exists ('socket _ import_stream ') {$ socket = socket_import_stream ($ resource ); socket_set_option ($ socket, SOL_TCP, TCP_NODELAY, (int) $ parameters-> tcp_nodelay);} return $ resource ;}
Production. ERROR
Configproduction
Folder? Is there a cache. php file? In this case, the external configurations will be overwritten.