PHP function memcache_decrement gives strange output

Sumit Datta sumitdatta at gmail.com
Mon Aug 20 06:13:35 UTC 2007


Thanks,
Thanks for pointing it out. If its in the protocol, it is fine.

On 8/18/07, Dustin Sallings <dustin at spy.net> wrote:
>
> On Aug 18, 2007, at 1:13, Mikael Johansson wrote:
>
> > This seems to be a memcached issue, a quick telnet session shows that
> > setting a value to for example "10" and then fetching the same value
> > returns a two byte space padded response like "9 ", most likely due to
> > the fact that memcached stores and modifies counters just like any
> > other
> > string value and does not adjust the item length on decrement.
> >
> > To get around this problem in PHP you could cast the result to
> > (int) if
> > you know you're fetching a counter, or use the return value from
> > memcache_decrement() which is the new number but integer converted.
>
>         The protocol specification mentions this specifically.
>
> --
> Dustin Sallings
>
>
>


--
Thanks
=Code is Poetry=
Sumit Datta
Web Developer


More information about the memcached mailing list