Ticket #187 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

eaccelerator_put and $ttl

Reported by: pyro Assigned to: somebody
Priority: major Milestone: 0.9.6
Component: eAccelerator Version: 0.9.5
Keywords: Cc: kmike

Description

The documentation seems to indicate that $ttl in the call to eaccelerator_put should be the number of seconds until the data should expire. In the past, I thought that it needed a unix time argument ($ttl+time()). If I pass a number of seconds, the key is immediately expired. If I pass a unix time, eaccelerator_list_keys shows each key with a negative ttl.

eAccelerator: 0.9.5 PHP: 5.1.6 pl7 (gentoo), 5.1.6 (suse) Apache: 2.2.3 (gentoo), 2.2.0 (suse)

test code:

<?php

    function test($secs, $time, $data) {
        $ttl = $secs;
        ($time === true) && $ttl += time();
        $time = ($time ? 'time' : 'secs');
        echo "test:$secs:$time returns " . var_export(eaccelerator_put("test:$secs:$time", $data, $ttl), true) . "\n";
    }

    $data = serialize(split(' ', 'one two three four five six seven'));

    echo '<pre>';

    test(30, false, $data);
    test(60, false, $data);
    test(90, false, $data);
    test(30, true, $data);
    test(60, true, $data);
    test(90, true, $data);

    $keys = eaccelerator_list_keys();
    usort($keys, create_function('$a,$b', 'return strcmp($a["name"], $b["name"]);'));

    echo "\nname\t\t\tcreated\t\tttl\n";
    foreach ($keys as $key)
        echo "{$key['name']}\t\t{$key['created']}\t{$key['ttl']}\n";

    echo '</pre>';
?>

Results:

test:30:secs returns true
test:60:secs returns true
test:90:secs returns true
test:30:time returns true
test:60:time returns true
test:90:time returns true

name			created		ttl
test:30:secs		1160684762	-1
test:30:time		1160684762	-1973597742
test:60:secs		1160684762	-1
test:60:time		1160684762	-1973597712
test:90:secs		1160684762	-1
test:90:time		1160684762	-1973597682

Change History

10/13/06 14:05:03 changed by kmike

  • cc set to kmike.

Looks like despite the "expired" state of the keys, you still can eaccelerator_get() them.

10/17/06 04:44:23 changed by pyro

  • milestone set to 0.9.5.

10/19/06 16:29:02 changed by tomlove

  • status changed from new to closed.
  • resolution set to fixed.

This was fixed in the final release of 0.9.5, available for a few days now. It's a bug in the reporting. TTLs are always relative.

10/20/06 00:57:40 changed by tomlove

  • status changed from closed to reopened.
  • resolution deleted.

Sorry, didn't check source. Bug indicated as fixed but not.

cache.c, rev 276, line 635:

if (p->ttl < t) {

Equality is wrong way round. Should be:

if (p->ttl > t) {

11/04/06 14:13:34 changed by bart

  • status changed from reopened to closed.
  • resolution set to fixed.
  • milestone changed from 0.9.5 to 0.9.6.

Damn, I think I'm stupid :p It should be really fix in rev 283.