php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56138 when using ->set() with an expiration, values come back wrong when -> get
Submitted: 2004-07-21 14:04 UTC Modified: 2004-07-22 02:45 UTC
From: jmat at shutdown dot net Assigned:
Status: Not a bug Package: memcache (PECL)
PHP Version: 5CVS-2004-07-21 (dev) OS: Mac OSX
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jmat at shutdown dot net
New email:
PHP Version: OS:

 

 [2004-07-21 14:04 UTC] jmat at shutdown dot net
Description:
------------
when setting a memcache value, and you specify an expiration time, the 
module appears to "double" serialize the value, so when you retrieve it 
later, it's still in a serialized string format.

Reproduce code:
---------------
<?php

$memc = memcache_pconnect("localhost",11211);
$values = array(1,2,3,4,5,6,7,8,9);
echo "Values: \n";
print_r($values);
echo "\n------------------------------\n";

$memc->set("myVals",$values,100);
$newValues = $memc->get("myVals");

echo"New Values:\n";
print_r($newValues);
echo "\n";

?>

Expected result:
----------------
Values: 
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
    [5] => 6
    [6] => 7
    [7] => 8
    [8] => 9
)

------------------------------
New Values:
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
    [5] => 6
    [6] => 7
    [7] => 8
    [8] => 9
)

Actual result:
--------------
Values: 
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
    [5] => 6
    [6] => 7
    [7] => 8
    [8] => 9
)

------------------------------
New Values:
a:9:{i:0;i:1;i:1;i:2;i:2;i:3;i:3;i:4;i:4;i:5;i:5;i:6;i:6;i:7;i:7;i:8;i:8;i:9;}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-21 14:05 UTC] jmat at shutdown dot net
this is using php 5.0 and memcache module 1.20
 [2004-07-22 02:45 UTC] tony2001@php.net
Expire time is the 4th parameter of set() function, check the docs: http://php.net/memcache_set
Don't use any values of flags parameter different from false and MEMCACHE_COMPRESSED. The function should check it, I'll probably change this in the future.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC