Comments (8)
It works as expected here using both Predis v0.6.6 (the current stable release) and v0.7.0-dev (using the most recent commit from the master branch) so I can't reproduce your problem.
How are you verifying that the keys end up in the wrong database?
from predis.
I was just verifying it manually using the redis-cli. Maybe because I am just plainly running the redis-server from its source directory. I'll try to pass a config file to the redis server and see what happens.
from predis.
You can verify that Predis is sending the SELECT
command with the correct arguments by launching ./redis-cli MONITOR
.
Alternatively you can start redis with an empty database and execute the following snippet:
$parameters = array(
'host' => '127.0.0.1',
'port' => 6379,
'database' => 15
);
$client = new Predis\Client($parameters);
$client->set("foo", "bar");
$client->select(10);
$client->set("foo", "bar");
$info = $client->info();
echo "DB-0: ", isset($info['db0']) ? 'not empty' : 'empty', "\n";
echo "DB-10: ", isset($info['db10']) ? 'not empty' : 'empty', "\n";
echo "DB-15: ", isset($info['db15']) ? 'not empty' : 'empty', "\n";
If you get the following output then everything is fine:
DB-0: empty
DB-10: not empty
DB-15: not empty
from predis.
I actually emptied my redis server.
I started redis cli using redis-cli MONITOR
and here is what I got
+1319541819.515487 "MONITOR"
+1319541866.517235 "SELECT" ""
+1319541866.517884 "RPUSH" "queue:item" "item1"
redis version is 2.0.3-2
php version is 5.3.6
predis version is 0.6.0
Where can I find 0.6.6
or 0.7.0
every time i click this https://github.com/nrk/predis/zipball/master I get 0.6.0
from predis.
Hmm yeah it looks like this link generates a file named predis-v0.6.0-521-g29f26b0.zip
but it really contains v0.7.0-dev as indicated by the VERSION
file (it's probably a bug of GitHub, I don't know why). Anyway you could try downloading v0.6.6 from the tags page.
That said, the strange thing is that you should be seeing "SELECT" "15"
instead of "SELECT" ""
(which means that the client is passing an empty argument to Redis) in the output of your MONITOR
session but I really can't understand why it happens since I can't reproduce your problem using the same versions under Ubuntu 11.04 and other combinations on a couple of different virtual machines.
Can you double check the problem by running the same test on a different server / configuration?
from predis.
So I downloaded 0.6.6 from this link http://github.com/nrk/predis/zipball/v0.6.6
The 0.6.6 doesn't contain an autoloader so I just added the Predis.php
file.
I tried to remove the redis snippets out of my class and created a separate file which just contains the push query here is how it looks . This one outputs "SELECT" "15"
twice.
redis_push_test.php
require_once 'predis/RedisClient.php';
$r = new Predis\Client($remote_single_server);
//did the select part for a purpose based on what I experienced above on my localhost
$r->select($remote_single_server['database']);
$r->rpush("queue:test","queue from remote client");
Here is my RedisClient.php
include_once 'predis/lib/Predis.php';
$single_server = array(
'host' => '127.0.0.1',
'port' => 6379,
'database' => 15
);
$remote_single_server = array(
'host' => '10.241.54.128',
'port' => 6379,
'database' => 15
);
Here is a class which follows the class template of gearman-manager. This is a gearman worker. I trimmed the code to keep it simple. This one outputs "SELECT" ""
once
worker.php
require_once 'predis/RedisClient.php';
class siteAnalyzer
{
/**
* Run method
*
* @param mixed $job
* @param array $log
* @return nothing
*/
public function run($job, &$log)
{
$workload = json_decode($job->workload(),true);
$page = $workload;
$r = new Predis\Client($remote_single_server);
$r->select($remote_single_server['database']);
$r->rpush("queue:test","query here");
return json_encode(true);
}
}
EDITED: Typographical errors.
from predis.
I have resolved this by creating a static class for the configuration file.
from predis.
If you add a geometry, use this command:
$redis->geoadd('channel', $lon,$lat,'ticket');
from predis.
Related Issues (20)
- Cache configuration objects (to support memory, number of keys, etc)
- [v3] cherry-pick opt out setinfo for v3 HOT 1
- Update CLIENT-SETINFO to support suffixes HOT 1
- Missing BITFIELD_RO support HOT 1
- psubscribe seems to swallow exit, exceptions, disconnect, quit calls HOT 4
- Add support for GEOSHAPE index fields and WITHIN and CONTAINS query operators
- Error while writing bytes to the server HOT 3
- Error on RPOP expects exactly 1 argument, 2 given HOT 2
- Explain `expireResoluton` for `SET` HOT 1
- Improve connection speed by running fewer commands
- Question: the `ClientInterface::eval` signature and PhpRedis HOT 1
- Connect to Sentinel with username: how to implement right ? HOT 3
- Add support for HSCAN [NOVALUES]
- Add command filter for CLIENT KILL to support maximum age via [MAXAGE] option
- Support XREAD, XREADGROUP reading from last message of stream
- Supporting redis unstable commands
- Consider master-link-status state when selecting slaves
- PSR-7 compatible stream abstraction HOT 4
- Cannot use 'EVAL_RO' with redis-cluster HOT 2
- unexpected result using plain Redis queries in PHP using predis HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from predis.