CAS Token Difference SDK Version 1.2 vs 2.0.3

Hi. I am in the middle of upgrading our project from v1.2 to v2.0.3 of the PHP SDK.

I am having an issue with CAS tokens. In v1.2 they appear to be integers, for example: 1008175711484384512. In v2.0.3 they now appear to be a resource, example: Resource id #202. When using get_resource_type() on the resource it returns: CouchbaseCAS.

Is there any way to work with the resource (CouchbaseCAS) to get the same value as the old SDK?


Hey nobey,

Due to the fact that PHP is not capable of representing large 64-bit integers, we were forced in a lot of cases to returns strings and parse strings, this incurred a significant performance penalty. Since CAS values are not intended to be manipulated or stored for any period of time beyond the actively executing script, we decided to expose it as a resource instead (which internally is a 64-bit integer pointer).

Cheers, Brett

Is the CouchbaseCAS resource meant to be passed into $options array when used with methods that support using CAS in conjunction with its operation?

Hi, I am facing the same issue and I need CAS value for temporary storage. I use this value for notifying user if they are updating outdated version of document.

Is there at all any way out to this? Is there any other way to store version?

@brett19: PHP is actually capable of representing large 64-bit integers as long you’re on a 64bit system with 64bit PHP installed:

$ php -r 'var_dump(PHP_INT_MAX);'

Would it be possible to detect whether the current environment supports 64bit integers and when it does provide us with the actual int?

Hi people
any response of anupmanekar´s question?
is possible to retrieve value of CAS?

I have the same problem, I want to get a Couchbase document (JSON document) with a PHP API and pass all the information, including the appropriate CAS (type cast because there is no resource type in AngularJS), to the front-end (AngularJS). Then make some operations and return it to the PHP API to store it in database. For sure, I want to check the correct CAS to avoid some concurrency problems.

As @brett said, at the moment php SDK does not reveal CAS content. But will will expose it in byte string in next release.

Follow this ticket please