Try using memcache_add() instead of memcache_set()

On Mon, Feb 16, 2009 at 2:07 AM, ehsmeng <[email protected]> wrote:

>
> Hi list,
>
> My memcache_increase() code below seems to misbehave under load.
>
> If any would take a guess, would this possibly be in memcached, the
> php interface or most likely in my code?
>
> The returned value of this function sometimes is 2147483647 (when
> increase_by is 1).
>
> Thanks,
> Marcus
>
> function memcache_increase_site ($key, $increase_by)
> {
>    $mc = memcache_site_singleton ();
>
>    if (false === $mc)
>    {
>        return false;
>    }
>
>    $val = memcache_increment ($mc, $key, $increase_by);
>    if (false === $val)
>    {
>        if (false === memcache_set ($mc, $key, $increase_by, 0, 0))
>        {
>            return false;
>        }
>        else
>        {
>            return (int)$increase_by;
>        }
>    }
>    else
>    {
>        return (int)$val;
>    }
> }

Reply via email to