GithubHelp home page GithubHelp logo

Comments (8)

nrk avatar nrk commented on June 15, 2024

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.

geocine avatar geocine commented on June 15, 2024

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.

nrk avatar nrk commented on June 15, 2024

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.

geocine avatar geocine commented on June 15, 2024

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.

nrk avatar nrk commented on June 15, 2024

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.

geocine avatar geocine commented on June 15, 2024

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.

geocine avatar geocine commented on June 15, 2024

I have resolved this by creating a static class for the configuration file.

from predis.

inayir avatar inayir commented on June 15, 2024

If you add a geometry, use this command:
$redis->geoadd('channel', $lon,$lat,'ticket');

from predis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.