8000 Method pexpire() doesnot exists · Issue #174 · phpredis/phpredis · GitHub
[go: up one dir, main page]

Skip to content

Method pexpire() doesnot exists #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ukko opened this issue May 5, 2012 · 14 comments
Closed

Method pexpire() doesnot exists #174

ukko opened this issue May 5, 2012 · 14 comments

Comments

@ukko
Copy link
ukko commented May 5, 2012
$r = new Redis();
$r->connect('127.0.0.1');
$r->set( 'ptest', 'test' );
var_dump( $r->pexpire( 'ptest', 5000 ) );
var_dump( $r->pttl( 'ptest' ) );

output

PHP Fatal error:  Call to undefined method Redis::pexpire() in /www/phpredis-phpdoc/test.php on line 6
PHP Stack trace:
PHP   1. {main}() /www/phpredis-phpdoc/test.php:0
@nicolasff
Copy link
Member

Fixed by #175.

@ukko
Copy link
Author
ukko commented May 9, 2012
$r = new Redis();
$r->connect('127.0.0.1');
$r->set( 'ptest', 'test' );
$r->persist('ptest');
var_dump( $r->pexpire( 'ptest', 1500 ) );
var_dump( $r->pttl( 'ptest' ) );

Output

bool(false)
int(-1)

@michael-grunder
Copy link
Member

Man this is weird,

When I run your script I get this:

bool(true)
int(1499)

@ukko
Copy link
Author
ukko commented May 9, 2012

My mistake, sorry :-(

@ukko
Copy link
Author
ukko commented May 17, 2012

Hmm .. It seems to me that the problem is that I am using 32 bit system, and you work on a 64 bit operating system.

Error was not fixed.

$r = new Redis();
$r->connect('127.0.0.1');
$r->set( 'ptest', 'test' );
$r->persist('ptest');
var_dump( $r->pexpireAt( 'ptest', 1555555555005) );
var_dump( $r->ttl( 'ptest' ) );
var_dump( $r->pttl( 'ptest' ) );
var_dump( $r->get('ptest') );

output

bool(true)
int(-1)
int(-1)
bool(false)

redis MONITOR

1337284780.287018 [0 127.0.0.1:33019] "SET" "ptest" "test"
1337284780.311217 [0 127.0.0.1:33019] "PERSIST" "ptest"
1337284780.311385 [0 127.0.0.1:33019] "PEXPIREAT" "ptest" "777393853"
1337284780.311555 [0 127.0.0.1:33019] "TTL" "ptest"
1337284780.311688 [0 127.0.0.1:33019] "PTTL" "ptest"
1337284780.311816 [0 127.0.0.1:33019] "GET" "ptest"

uname -a
Linux u 3.2.0-24-generic #38-Ubuntu SMP Tue May 1 16:21:07 UTC 2012 i686 i686 i386 GNU/Linux

@nicolasff nicolasff reopened this May 17, 2012
@nicolasff
Copy link
Member

Thanks @ukko, reopened.

@michael-grunder
Copy link
Member

Nicolas,

What about just treating it like a string, and doing some very simple check that all of the characters are 0-9? This would mean we would need to return a string as well, meaning the client would have to convert the return value.

@nicolasff
Copy link
Member

Indeed that would work, but at the cost of dumbing down 64-bit clients... I checked on a 32-bit VM and PHP converts them to float. I guess that could be an acceptable alternative for 32-bit clients. What do you think?

@michael-grunder
Copy link
Member

I'm sorry, what types are converted to float in 32 bit? This could work if the float is wide enough. It has been forever since I've coded for 32 bit. :)

The other solution, is to #ifdef 32 bit vs. 64 bit, but that seems brutal.

8000

nicolasff added a commit that referenced this issue May 17, 2012
Timeouts in milliseconds overflow longs on 32-bit architectures.
This fix replaces the integer return with a float on 32-bit.
Ref: GitHub issue #174.
@nicolasff
Copy link
Member

@michael-grunder refresh the page, I did put an #ifdef :)

@nicolasff
Copy link
Member

@ukko Could you please try it out? I've change methods like pexpireat to automatically convert the input parameter to string and return floats for methods like pttl.

@ukko
Copy link
Author
ukko commented May 17, 2012
bool(true)
float(0)
float(0)
string(4) "test"

Dont work :-(

nicolasff added a commit that referenced this issue May 17, 2012
Tested on 32-bits, addresses GitHub issue #174.
@nicolasff
Copy link
Member

@ukko sorry about that, I made a new fix and tested it on a 32-bit VM with success. It returns a string instead of a long, I'm afraid there's no way around it.

@ukko
Copy link
Author
ukko commented May 17, 2012

Thank you, Nicolas and Michael. Its work! :-)

bool(true)
int(218263835)
string(12) "218263835464"
string(4) "test"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
0