Coder Social home page Coder Social logo

codeigniter-redis's People

Contributors

aw avatar axelay avatar danhunsaker avatar integrii avatar joelcox avatar panman avatar swznd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codeigniter-redis's Issues

Support for multiple Redis servers

Hi,

I was trying to modify the code to make this work but there's some magic CodeIgniter 🌈 stuff going on which I don't fully understand.

TLDR; I got it working, but it's a total hack.

Essentially I'm trying to configure two separate Redis servers - one for read 📖 requests, one for write 📝 requests.

I pushed a new branch which adds this functionality but pretty much breaks previous functionality, as seen here: https://github.com/aw/codeigniter-redis/commit/6fc6dd1ef732ffa4671e39b3438327e351552993

I'm also unsure how this affects Sparks since I don't use them.

Perhaps you can have a look at the changes I made, and suggest some improvements to enable backwards compatibility with the config file / usage (ie: not requiring $this->redis->connect() if a scope isn't defined) ?

Let me know what's possible when you have a chance.

Thanks!

Argument parsing for lists

There are a few inconsistencies when performing operation on lists:

  • Non-associative arrays aren't stripped from their indexes, causing the indexes to also be included in the list.
  • Range commands on lists are not parsed correctly.

Originally reported by Benjamin MA.

Some data does not properly return from redis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ibG9uZ2l0dWRlXCI7czoxMTpcIi0xMjIuMTgzMDg4XCI7czo0OlwidGltZVwiO2k6MTM3NjAzMTA5OTtzOjQ6XCJjaXR5XCI7czo2OlwiUmVudG9uXCI7czo1Olwic3RhdGVcIjtzOjI6XCJXQVwiO31pOjI5O2E6Nzp7czoyOlwiaWRcIjtzOjY6XCI2MjMzNjlcIjtzOjQ6XCJuYW1lXCI7czoxMjpcIkNsdm9lciBDcmVla1wiO3M6ODpcImxhdGl0dWRlXCI7czo5OlwiNDcuNTE1NTg1XCI7czo5OlwibG9uZ2l0dWRlXCI7czoxMTpcIi0xMjIuMjA1MDQ3XCI7czo0OlwidGltZVwiO2k6MTM3NjAzMTA5OTtzOjQ6XCJjaXR5XCI7czo2OlwiUmVudG9uXCI7czo1Olwic3RhdGVcIjtzOjI6XCJXQVwiO319Ig=="

$this->redis->set("test", $data);

$brokenData = $this->redis->get("test");

echo $brokenData;

the data you see will be cut off.

Unable to connect to redis with a correct password

I'm having trouble connecting to a remote instance of redis. I have a custom port number and a password. I think it might be a bug.

The thing is I can use the redis-cli on the machine to connect to the port:

redis-cli {portnumber}
-> AUTH {password}
etc..

but I can't connect to when I set the same settings.

$config['redis_host'] = {IP} // IP address or host
$config['redis_port'] = {portnumber};
$config['redis_password'] = {password};

I thought it could be a port firewall issue but it is not as I deliberately tried an invalid port and got the error.

Could not connect to Redis at {ip}:{port}

which means this is not a port issue.

..with the correct password, I get the error

Could not connect to Redis, invalid password

I have tested the setting without a password and it works.

The password used for my testing was password and has no special characters.

The library sometimes returns OK when getting data

The only place in the library I can find the string 'OK' is in the authentication piece. It seems like whenever this bug happens, the redis lib will only return OK repeatedly and sometimes "1" for a good few queries.

Strings containing '/n' terminate early when you 'get' them from redis.

I was submitting html(generated with php) into redis for caching. When I tried to retrieve the page it would only return part of the string.

After trying to find a bug in my own code. I checked redis which was definitely storing the whole string. Codeignitor redis would only return part of the string. I tested it in Predis which returned the whole string (as expected).

Example:

$string = "<div><span>Something</span>
<p>Somestuff</p>
</div>
";
$this->redis->set('test',$string);
print $this->redis->get('test');

//Output (not as expected)
<div><span>Something</span>

After playing around with it I realised that string always terminated where an /n appeared in $string (doing a get with redis-cli shows /n in a strings stored).

I tried to find the problem in the codeignitor-redis code but could not.

Work Around Solution:

Do a string replace before setting a string that could contain \n. Hopefully this helps someone else who experienced the same thing.

$string = str_replace("\n",'',$string);

Sorry if this is not a good bug report. It is my first attempt at one.

使用scan命令时返回值出错

以下为错误示例:
php代码:
var_dump($this->redis->command('scan 0'));
输出结果:
array(2) {
[0] =>
string(3) "768"
[1] =>
string(11) "$9
file_29"
}

Implement set commands (sadd,srem,smembers,sismember,scard)

I had a need to use some of the set-related commands in Redis for my app,
so I went ahead and implemented them.
It'd be great if you can look over it and merge it into the master if it looks good.
*I've wrote tests to go along with it too

Set json string as value

I'm trying the following

$value = json_encode($jsonArrayed);
$response = $redis->command('set test ' .$value);

But I get bad syntax error.
I've also tried with

$value = '''.json_encode($jsonArrayed).''';
$value = '''.addslashes(json_encode($jsonArrayed)).''';

But no luck.

Any idea how to set a json string as a value?

Deprecating this library

I'm no longer an active CodeIgniter user and thus find it harder to dedicate time to maintaining this library. There are some serious bugs which need to be taken care of, but fixing them has been shown to be difficult. The PHP landscape has changed dramatically in the past few years, favoring framework independent packages, enabled by things like Composer/Packagist.

After 148 stars and 63 forks I plan on deprecating this library next week. The source will remain available on GitHub, but I'll encourage new users to use Predis instead. This is also the recommended update path for existing users.

Thank you for using this library. I also want to extend my thanks to every contributor who helped fixing bugs and/or worked on adding cool features.

Multi line bulk responses are truncated by _bulk_reply()

In _bulk_reply() , we test for the number of bytes to read from the initial response, and then attempt to read that response via fgets(). The problem is, if the bulk reply is the result of a command like INFO, the response will be truncated as soon as the first \r\n is encountered.

Simply changing fgets() to fread() in that function fixes it, as fread() will simply read the requested length, however a call to rtrim() is needed to remove the right most \r\n.

All tests pass once that's done, and multi line replies (that aren't multi bulk replies) return as expected. Do you want a pull request for this? It's extremely trivial. I was halfway considering implementing a concrete info() method to break it down into a nice convenient array (I probably will, I'm just not sure if you want it or not).

Cheers!
--Tim

Problem with special character(SPACE, '!', '%', etc.) in keys and values

Hi, I just found that this library cannot deal with almost ANY special characters. I was trying to store some JSON within some keys, however I found that nothing passed to the redis.

Then I tried the following with no luck:

$this->redis->command('set ' .'key1' . ' ');
$this->redis->command('set ' .'key1' . '!');
$this->redis->command('set ' .'key1' . '%');

I think this may due to the key and the value were not proper encoded. Wish this issue report can be a little help.

_auth() never reaches show_error() on an authentication error.

The _auth() method does a very simple check to see if authentication worked:

$request = $this->_encode_request('AUTH ' . $password);
if (! $this->_write_request($request))
{

In the case of a failed auth attempt, _write_request() will still evaluate to 'true' as an error string will be returned (e.g. 'invalid password').

There are three options here:

  • Just call _write_request() in _auth() and don't care if it works, since failures will be logged anyway
  • Make a _write_auth_request() that returns an explicit bool, so people can throw / error if authentication failed
  • Add an $auth bool to the existing _write_request() to be passed on to _read_request() indicating that any failure should return false

I was leaning in the third direction, but wanted some feedback prior to implementing that.

Commands with 3+ arguments don't work

I attempted to use SETEX and found, to my dismay, that it wasn't getting all of the arguments it wanted. Upon inspection of the __call() method, I quickly discovered why. I have a simple fix for this, which I will issue a pull request for in just a minute. I don't think it will fix Issue #18 (though it might provide a cleaner workaround), so I'm creating a new issue for it here.

Basically, the fix is to use implode() on the arguments array, since the logic in _encode_request() already properly handles an argument list separated by spaces. This is only done, of course, if the first argument is not an array. The second argument to _encode_request() is not sent in this case.

fgets() must greater than 0 (error from $this->redis->get() )

private function _bulk_reply()
{

    // Get the amount of bits to be read
    $value_length = (int) fgets($this->_connection);

    return fgets($this->_connection, $value_length + 1);

}

this function fixed problem =
private function _bulk_reply()
{

    // Get the amount of bits to be read
    $value_length = (int) fgets($this->_connection);

    return @fgets($this->_connection, $value_length + 1);

}

Remove plaintext commands

v0.4 will remove plaintext commands for methods, except via the Redis::command method. This will break the current API, but I don't suspect that many people will be affected, due to the overloading capabilities of the library.

method _bulk_reply is not returning the correct data

Redis protocol sends a "CRLF" when it returns a string with zero length ($0), but when it returns a string "-1" ($-1) length it does not have a "CRLF". Solution is to remove "CRLF" when its a zero length string.

-- CIRedis::_bulk_reply --
remove: if ($value_length <= 0) return NULL;
add: if ($value_length <= 0) {
add: if ($value_length == 0) {
add: fgets($this->_connection);
add: }
add: return NULL;
add: }

Fixed intermittent part of the large packet is lost

in __construct() function

$this->_connection = @fsockopen($this->_ci->config->item('redis_host'), $this->_ci->config->item('redis_port'), $errno, $errstr, 3);

to

$this->_connection = @stream_socket_client("tcp://".$this->_ci->config->item('redis_host').":".$this->_ci->config->item('redis_port'), $errno, $errstr, 3);

and in _bulk_reply() function

private function _bulk_reply()
{
    $value_length = (int) fgets($this->_connection);

    if($value_length > 0 && $this->_connection) {
        return fgets($this->_connection, $value_length + 1);
    }
}

Cannot get limit to work - could be related to spaces?

Hi, I am trying to sort a list using the following:
$users = $this->redis->sort('users', array('by' => '*->time_created'), array('limit' => '0 2'));
But I always end up with FALSE, whereas
$users = $this->redis->sort('users', array('by' => '*->time_created'), array('get' => '*->username'));
works fine although it is not what I am looking for.

Am I doing something idiotic here or there is an issue?
For the time being I use:
$users = $this->redis->command("sort users by *->time_created limit 0 2");
but would be nice to have a limit filter that works :)

Keep up the good work!

No way to check if redis is running

So when my redis server is not running and I try to initialize the library : $this->load->library('Redis') , it throws an error straight away via show_error() CI function which gives a 500 http response code.

I think It will be great to have a function like getStatus() to check if redis is on and then running the query. So something like :

if($this->redis->getStatus()) 
    $this->redis->set($key, $value);

How can i set time for expire.

Hello,

How can i set particular cache for particular time. ?

I have tried using this : $this->redis->set('foo2', 'bar',500); but its not working. please some one look in to this.

Thanks,
Hardik Devariya

_auth returns "invalid password" when $password === ''

Running PHP 5.3.15. With $config['password'] set to "" (not set), $password argument is actually set and doesn't default to NULL.

I changed if($password !== NULL) to if($password !== NULL && $password !== '')

which works for me. May be a better way.

I'm a GitHub n00b so if there's something I should do here, please let me know. Thanks.

Redis pipeline - batch get

Thanks for this great script!
Can you add pipeline or some other "batch get" solution for this script?
I think it will be very helpful for me and others :)

`_single_line_reply()` is truncating large strings

While I was retrieving some JSON (rather huge sets) I noticed that _single_line_reply() was returning only a (large) random chunk of what it should. The chunk was usually 8192 bytes, but sometimes 16k. The same thing happened with base64 encoded data larger than ~32k .

Identical behavior happens when data is just serialized prior to setting. Yet, a GET from redis console produces the entire thing perfectly.

My understanding of fgets() is the same as in the documentation:

Reading ends when length - 1 bytes have been read, on a newline (which is included in the return value), or on EOF (whichever comes first). If no length is specified, it will keep reading from the stream until it reaches the end of the line.

Try it with any large serialized array ( > 8k) e.g.

$redis->set('foo', serialize($big_array));

Then observe what you see via $redis->get('foo') vs what you see via GET foo in the console. I checked the points at which it chomped the data and there was no newline (escaped or otherwise) at that point. Always at 8k or 16k.

Can anyone reproduce this?

In the Constructor, connection error should show $config['port']

// Display an error message if connection failed
if ( ! $this->_connection)
{
show_error('Could not connect to Redis at ' . $config['host'] . ':' . $config['redis_port']);
}

should be $config['port'] instead, right? the port wasn't appearing in the error message for me.

Add tests for each major command

Each major Redis command should be tested so there is a more granular way of ensuring the quality of this lib. Each test should include all notations this lib supports (except the plain text version, of course).

undefined variable

i received an undefined variable notice on line 361 of the library- can be fixed by initialising the response variable with an empty array

Reorganize test

I just migrated the unit test controller to PHPUnit, but the quality of these tests is seriously lacking. These tests are rather integration tests (black box approach) rather than proper unit tests.

How can i use this in cli?

Hello, thank you for your code, but i have a problem.How can i use this in cli?
My error:
php index.php crons/DymcCodeCron sendMsg

A PHP Error was encountered

Severity: Warning
Message: Redis::__construct() expects exactly 0 parameters, 1 given
Filename: /system/core/Loader.php
Line Number: 1281

Backtrace:
File: /controllers/crons/DymcCodeCron.php
Line: 10
Function: library

    File: /index.php
    Line: 315
    Function: require_once

multi & exec hmget failed

Hi again.
When using multi & exec with hmget function, every third request receive a correct response.
Checked without multi and it works...
Any idea?

$this->redis->multi();
$this->redis->hmget('member.123',array('profile'));
$this->redis->hmget('member.234',array('profile'));
$this->redis->hmget('member.345',array('profile'));
$this->redis->hmget('member.456',array('profile'));
var_dump($this->redis->exec());

array(970) {
[0]=>
string(1) "$"
[1]=>
bool(false)
[2]=>
string(189) "GOOD RESPONSE"
[3]=>
string(1) "$"
}

Thanks!

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.