Skip to content

CAS tokens broken at upper 64 bit values #159

@sqmk

Description

@sqmk

When retrieving a CAS token in high 64-bit space, PHP converts the token to an exponential notation float, which loses precision. Passing this value back to check and set methods will fail due to the value not matching what memcached provided. This ultimately breaks the CAS implementation in PHP.

Considering even the documentation expects this value to be 64-bit value, perhaps it's time to add the support for getting potentially high valued CAS tokens? If it was represented in PHP user land as a string and converted to either a 32-bit or 64-bit unsigned value back to libmemcached depending on env, could work cross platform. Unfortunately, this would result in BC break for folks actually expecting a float to be returned in the CAS key. Or, for better BC, provide a new option to set via Memcached::setOption to handle returning/converting of CAS token values differently per circumstance.

My use case is via NDB w/ memcached. NDB does not autoincrement new CAS tokens starting from 0, but instead, generates the token based off hardware fingerprint and other info. The tokens are generally in the 64-bit space.

I could see this very same problem coming up via long running memcached servers that generate a stupid high amount of CAS tokens. These tokens could ultimately end up with large values, breaking tokens via this Memcached library. The good thing is, the likelihood of this happening is probably slim. However, this problem could potentially halt applications when CAS token values start encroaching 64 bit values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions