-
Notifications
You must be signed in to change notification settings - Fork 803
/
Copy pathcouchbase.php
3618 lines (3257 loc) · 116 KB
/
couchbase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Couchbase extension stubs
* Gathered from https://docs.couchbase.com/sdk-api/couchbase-php-client-2.3.0/index.html
* Maintainer: [email protected]
*
* https://github.com/couchbase/php-couchbase/tree/master/api
*/
/**
* INI entries:
*
* * `couchbase.log_level` (string), default: `"WARN"`
*
* controls amount of information, the module will send to PHP error log. Accepts the following values in order of
* increasing verbosity: `"FATAL"`, `"ERROR"`, `"WARN"`, `"INFO"`, `"DEBUG"`, `"TRACE"`.
*
* * `couchbase.encoder.format` (string), default: `"json"`
*
* selects serialization format for default encoder (\Couchbase\defaultEncoder). Accepts the following values:
* * `"json"` - encodes objects and arrays as JSON object (using `json_encode()`), primitives written in stringified form,
* which is allowed for most of the JSON parsers as valid values. For empty arrays JSON array preferred, if it is
* necessary, use `new stdClass()` to persist empty JSON object. Note, that only JSON format considered supported by
* all Couchbase SDKs, everything else is private implementation (i.e. `"php"` format won't be readable by .NET SDK).
* * `"php"` - uses PHP serialize() method to encode the document.
* * `"igbinary"` - uses pecl/igbinary to encode the document in even more efficient than `"php"` format. Might not be
* available, if the Couchbase PHP SDK didn't find it during build phase, in this case constant
* \Couchbase\HAVE_IGBINARY will be false.
*
* * `couchbase.encoder.compression` (string), default: `"none"`
*
* selects compression algorithm. Also see related compression options below. Accepts the following values:
* * `"fastlz"` - uses FastLZ algorithm. The module might be configured to use system fastlz library during build,
* othewise vendored version will be used. This algorithm is always available.
* * `"zlib"` - uses compression implemented by libz. Might not be available, if the system didn't have libz headers
* during build phase. In this case \Couchbase\HAVE_ZLIB will be false.
* * `"off"` or `"none"` - compression will be disabled, but the library will still read compressed values.
*
* * `couchbase.encoder.compression_threshold` (long), default: `0`
*
* controls minimum size of the document value in bytes to use compression. For example, if threshold 100 bytes,
* and the document size is 50, compression will be disabled for this particular document.
*
* * `couchbase.encoder.compression_factor` (float), default: `0.0`
*
* controls the minimum ratio of the result value and original document value to proceed with persisting compressed
* bytes. For example, the original document consists of 100 bytes. In this case factor 1.0 will require compressor
* to yield values not larger than 100 bytes (100/1.0), and 1.5 -- not larger than 66 bytes (100/1.5).
*
* * `couchbase.decoder.json_arrays` (boolean), default: `false`
*
* controls the form of the documents, returned by the server if they were in JSON format. When true, it will generate
* arrays of arrays, otherwise instances of stdClass.
*
* * `couchbase.pool.max_idle_time_sec` (long), default: `60`
*
* controls the maximum interval the underlying connection object could be idle, i.e. without any data/query
* operations. All connections which idle more than this interval will be closed automatically. Cleanup function
* executed after each request using RSHUTDOWN hook.
*
* @package Couchbase
*/
namespace Couchbase;
/** If igbinary extension was not found during build phase this constant will store 0 */
define("Couchbase\\HAVE_IGBINARY", 1);
/** If libz headers was not found during build phase this constant will store 0 */
define("Couchbase\\HAVE_ZLIB", 1);
/** Encodes documents as JSON objects (see INI section for details)
* @see \Couchbase\basicEncoderV1
*/
define("Couchbase\\ENCODER_FORMAT_JSON", 0);
/** Encodes documents using pecl/igbinary encoder (see INI section for details)
* @see \Couchbase\basicEncoderV1
*/
define("Couchbase\\ENCODER_FORMAT_IGBINARY", 1);
/** Encodes documents using PHP serialize() (see INI section for details)
* @see \Couchbase\basicEncoderV1
*/
define("Couchbase\\ENCODER_FORMAT_PHP", 2);
/** Do not use compression for the documents
* @see \Couchbase\basicEncoderV1
*/
define("Couchbase\\ENCODER_COMPRESSION_NONE", 0);
/** Use zlib compressor for the documents
* @see \Couchbase\basicEncoderV1
*/
define("Couchbase\\ENCODER_COMPRESSION_ZLIB", 1);
/** Use FastLZ compressor for the documents
* @see \Couchbase\basicEncoderV1
*/
define("Couchbase\\ENCODER_COMPRESSION_FASTLZ", 2);
/**
* Compress input using FastLZ algorithm.
*
* @param string $data original data
* @return string compressed binary string
*/
function fastlzCompress($data) {}
/**
* Decompress input using FastLZ algorithm.
*
* @param string $data compressed binary string
* @return string original data
*/
function fastlzDecompress($data) {}
/**
* Compress input using zlib. Raises Exception when extension compiled without zlib support.
*
* @param string $data original data
* @return string compressed binary string
* @see \Couchbase\HAVE_ZLIB
*/
function zlibCompress($data) {}
/**
* Compress input using zlib. Raises Exception when extension compiled without zlib support.
*
* @param string $data compressed binary string
* @return string original data
* @see \Couchbase\HAVE_ZLIB
*/
function zlibDecompress($data) {}
/**
* Returns value as it received from the server without any transformations.
*
* It is useful for debug purpose to inspect bare value.
*
* @param string $bytes
* @param int $flags
* @param int $datatype
* @return string Document as it received from the Couchbase.
*
* @see \Couchbase\Bucket::setTranscoder()
*/
function passthruDecoder($bytes, $flags, $datatype) {}
/**
* Returns the value, which has been passed and zero as flags and datatype.
*
* It is useful for debug purposes, or when the value known to be a string, otherwise behavior is not defined (most
* likely it will generate error).
*
* @param string $value document to be stored in the Couchbase
* @return array Array with three values: [bytes, 0, 0]
*
* @see \Couchbase\Bucket::setTranscoder()
*/
function passthruEncoder($value) {}
/**
* Decodes value using \Couchbase\basicDecoderV1.
*
* It passes `couchbase.decoder.*` INI properties as $options.
*
* @param string $bytes Binary string received from the Couchbase, which contains encoded document
* @param int $flags Flags which describes document encoding
* @param int $datatype Extra field for datatype (not used at the moment)
* @return mixed Decoded document object
*
* @see \Couchbase\basicDecoderV1
* @see \Couchbase\Bucket::setTranscoder()
*/
function defaultDecoder($bytes, $flags, $datatype) {}
/**
* Encodes value using \Couchbase\basicDecoderV1.
*
* It passes `couchbase.encoder.*` INI properties as $options.
*
* @param mixed $value document to be stored in the Couchbase
* @return array Array with three values: [bytes, flags, datatype]
*
* @see \Couchbase\basicDecoderV1
* @see \Couchbase\Bucket::setTranscoder()
*/
function defaultEncoder($value) {}
/**
* Decodes value according to Common Flags (RFC-20)
*
* @param string $bytes Binary string received from the Couchbase, which contains encoded document
* @param int $flags Flags which describes document encoding
* @param int $datatype Extra field for datatype (not used at the moment)
* @param array $options
* @return mixed Decoded document object
*
* @see https://github.com/couchbaselabs/sdk-rfcs RFC-20 at SDK RFCs repository
*/
function basicDecoderV1($bytes, $flags, $datatype, $options) {}
/**
* Encodes value according to Common Flags (RFC-20)
*
* @param mixed $value document to be stored in the Couchbase
* @param array $options Encoder options (see detailed description in INI section)
* * "sertype" (default: \Couchbase::ENCODER_FORMAT_JSON) encoding format to use
* * "cmprtype" (default: \Couchbase::ENCODER_COMPRESSION_NONE) compression type
* * "cmprthresh" (default: 0) compression threshold
* * "cmprfactor" (default: 0) compression factor
* @return array Array with three values: [bytes, flags, datatype]
*
* @see https://github.com/couchbaselabs/sdk-rfcs RFC-20 at SDK RFCs repository
*/
function basicEncoderV1($value, $options) {}
/**
* Exception represeting all errors generated by the extension
*/
class Exception extends \Exception {}
/**
* Represents Couchbase Document, which stores metadata and the value.
*
* The instances of this class returned by K/V commands of the \Couchbase\Bucket
*
* @see \Couchbase\Bucket
*/
class Document
{
/**
* @var Exception exception object in case of error, or NULL
*/
public $error;
/**
* @var mixed The value stored in the Couchbase.
*/
public $value;
/**
* @var int Flags, describing the encoding of the document on the server side.
*/
public $flags;
/**
* @var string The last known CAS value of the document
*/
public $cas;
/**
* @var MutationToken
* The optional, opaque mutation token set after a successful mutation.
*
* Note that the mutation token is always NULL, unless they are explicitly enabled on the
* connection string (`?fetch_mutation_tokens=true`), the server version is supported (>= 4.0.0)
* and the mutation operation succeeded.
*
* If set, it can be used for enhanced durability requirements, as well as optimized consistency
* for N1QL queries.
*/
public $token;
}
/**
* A fragment of a JSON Document returned by the sub-document API.
*
* @see \Couchbase\Bucket::mutateIn()
* @see \Couchbase\Bucket::lookupIn()
*/
class DocumentFragment
{
/**
* @var Exception exception object in case of error, or NULL
*/
public $error;
/**
* @var mixed The value sub-document command returned.
*/
public $value;
/**
* @var string The last known CAS value of the document
*/
public $cas;
/**
* @var MutationToken
* The optional, opaque mutation token related to updated document the environment.
*
* Note that the mutation token is always NULL, unless they are explicitly enabled on the
* connection string (`?fetch_mutation_tokens=true`), the server version is supported (>= 4.0.0)
* and the mutation operation succeeded.
*
* If set, it can be used for enhanced durability requirements, as well as optimized consistency
* for N1QL queries.
*/
public $token;
}
/**
* Represents a Couchbase Server Cluster.
*
* It is an entry point to the library, and in charge of opening connections to the Buckets.
* In addition it can instantiate \Couchbase\ClusterManager to peform cluster-wide operations.
*
* @see \Couchbase\Bucket
* @see \Couchbase\ClusterManager
* @see \Couchbase\Authenticator
*/
class Cluster
{
/**
* Create cluster object
*
* @param string $connstr connection string
*/
public function __construct($connstr) {}
/**
* Open connection to the Couchbase bucket
*
* @param string $name Name of the bucket.
* @param string $password Password of the bucket to override authenticator.
* @return Bucket
*
* @see \Couchbase\Authenticator
*/
public function openBucket($name = "default", $password = "") {}
/**
* Open management connection to the Couchbase cluster.
*
* @param string $username Name of the administrator to override authenticator or NULL.
* @param string $password Password of the administrator to override authenticator or NULL.
* @return ClusterManager
*
* @see \Couchbase\Authenticator
*/
public function manager($username = null, $password = null) {}
/**
* Associate authenticator with Cluster
*
* @param Authenticator $authenticator
* @return null
*
* @see \Couchbase\Authenticator
* @see \Couchbase\ClassicAuthenticator
* @see \Couchbase\PasswordAuthenticator
*/
public function authenticate($authenticator) {}
/**
* Create \Couchbase\PasswordAuthenticator from given credentials and associate it with Cluster
*
* @param string $username
* @param string $password
* @return null
*
* @see \Couchbase\Authenticator
* @see \Couchbase\PasswordAuthenticator
*/
public function authenticateAs($username, $password) {}
}
/**
* Provides management capabilities for a Couchbase Server Cluster
*
* @see \Couchbase\Cluster
*/
class ClusterManager
{
/**
* The user account managed by Couchbase Cluster.
*/
public const RBAC_DOMAIN_LOCAL = 1;
/**
* The user account managed by external system (e.g. LDAP).
*/
public const RBAC_DOMAIN_EXTERNAL = 2;
final private function __construct() {}
/**
* Lists all buckets on this cluster.
*
* @return array
*/
public function listBuckets() {}
/**
* Creates new bucket
*
* @param string $name Name of the bucket
* @param array $options Bucket options
* * "authType" (default: "sasl") type of the bucket authentication
* * "bucketType" (default: "couchbase") type of the bucket
* * "ramQuotaMB" (default: 100) memory quota of the bucket
* * "replicaNumber" (default: 1) number of replicas.
*
* @see https://developer.couchbase.com/documentation/server/current/rest-api/rest-bucket-create.html
* More options and details
*/
public function createBucket($name, $options = []) {}
/**
* Removes a bucket identified by its name.
*
* @param string $name name of the bucket
*
* @see https://developer.couchbase.com/documentation/server/current/rest-api/rest-bucket-delete.html
* More details
*/
public function removeBucket($name) {}
/**
* Provides information about the cluster.
*
* Returns an associative array of status information as seen on the cluster. The exact structure of the returned
* data can be seen in the Couchbase Manual by looking at the cluster /info endpoint.
*
* @return array
*
* @see https://developer.couchbase.com/documentation/server/current/rest-api/rest-cluster-get.html
* Retrieving Cluster Information
*/
public function info() {}
/**
* Lists all users on this cluster.
*
* @param int $domain RBAC domain
*
* @return array
*
* @see \Couchbase\ClusterManager::RBAC_DOMAIN_LOCAL
* @see \Couchbase\ClusterManager::RBAC_DOMAIN_EXTERNAL
*/
public function listUsers($domain = RBAC_DOMAIN_LOCAL) {}
/**
* Fetch single user by its name
*
* @param string $username The user's identifier
* @param int $domain RBAC domain
*
* @return array
*
* @see \Couchbase\ClusterManager::RBAC_DOMAIN_LOCAL
* @see \Couchbase\ClusterManager::RBAC_DOMAIN_EXTERNAL
*/
public function getUser($username, $domain = RBAC_DOMAIN_LOCAL) {}
/**
* Creates new user
*
* @param string $name Name of the user
* @param \Couchbase\UserSettings $settings settings (credentials and roles)
* @param int $domain RBAC domain
*
* @see https://developer.couchbase.com/documentation/server/5.0/rest-api/rbac.html
* More options and details
* @see \Couchbase\ClusterManager::RBAC_DOMAIN_LOCAL
* @see \Couchbase\ClusterManager::RBAC_DOMAIN_EXTERNAL
*/
public function upsertUser($name, $settings, $domain = RBAC_DOMAIN_LOCAL) {}
/**
* Removes a user identified by its name.
*
* @param string $name name of the bucket
* @param int $domain RBAC domain
*
* @see https://developer.couchbase.com/documentation/server/5.0/rest-api/rbac.html
* More details
* @see \Couchbase\ClusterManager::RBAC_DOMAIN_LOCAL
* @see \Couchbase\ClusterManager::RBAC_DOMAIN_EXTERNAL
*/
public function removeUser($name, $domain = RBAC_DOMAIN_LOCAL) {}
}
/**
* Represents settings for new/updated user.
*
* @see https://developer.couchbase.com/documentation/server/5.0/rest-api/rbac.html
*/
class UserSettings
{
/**
* Sets full name of the user (optional).
*
* @param string $fullName Full name of the user
*
* @return \Couchbase\UserSettings
*
* @see https://developer.couchbase.com/documentation/server/5.0/rest-api/rbac.html
* More details
*/
public function fullName($fullName) {}
/**
* Sets password of the user.
*
* @param string $password Password of the user
*
* @return \Couchbase\UserSettings
*
* @see https://developer.couchbase.com/documentation/server/5.0/rest-api/rbac.html
* More details
*/
public function password($password) {}
/**
* Adds role to the list of the accessible roles of the user.
*
* @param string $role identifier of the role
* @param string $bucket the bucket where this role applicable (or `*` for all buckets)
*
* @return \Couchbase\UserSettings
*
* @see https://developer.couchbase.com/documentation/server/5.0/rest-api/rbac.html
* More details
*/
public function role($role, $bucket = null) {}
}
/**
* Represents connection to the Couchbase Server
*
* @property int $operationTimeout
* The operation timeout (in microseconds) is the maximum amount of time the
* library will wait for an operation to receive a response before invoking
* its callback with a failure status.
*
* An operation may timeout if:
*
* * A server is taking too long to respond
* * An updated cluster configuration has not been promptly received
*
* @property int $viewTimeout
* The I/O timeout (in microseconds) for HTTP requests to Couchbase Views API
*
* @property int $n1qlTimeout
* The I/O timeout (in microseconds) for N1QL queries.
*
* @property int $httpTimeout
* The I/O timeout (in microseconds) for HTTP queries (management API).
*
* @property int $configTimeout
* How long (in microseconds) the client will wait to obtain the initial
* configuration.
*
* @property int $configNodeTimeout
* Per-node configuration timeout (in microseconds).
*
* This timeout sets the amount of time to wait for each node within
* the bootstrap/configuration process. This interval is a subset of
* the $configTimeout option mentioned above and is intended to ensure
* that the bootstrap process does not wait too long for a given node.
* Nodes that are physically offline may never respond and it may take
* a long time until they are detected as being offline.
*
* @property int $configDelay
* Config refresh throttling
*
* Modify the amount of time (in microseconds) before the configiration
* error threshold will forcefully be set to its maximum number forcing
* a configuration refresh.
*
* Note that if you expect a high number of timeouts in your operations,
* you should set this to a high number. If you are using the default
* timeout setting, then this value is likely optimal.
*
* @property int $htconfigIdleTimeout
* Idling/Persistence for HTTP bootstrap (in microseconds)
*
* By default the behavior of the library for HTTP bootstrap is to keep
* the stream open at all times (opening a new stream on a different host
* if the existing one is broken) in order to proactively receive
* configuration updates.
*
* The default value for this setting is -1. Changing this to another
* number invokes the following semantics:
*
* * The configuration stream is not kept alive indefinitely. It is kept
* open for the number of seconds specified in this setting. The socket
* is closed after a period of inactivity (indicated by this setting).
*
* * If the stream is broken (and no current refresh was requested by
* the client) then a new stream is not opened.
*
* @property int $durabilityInterval
* The time (in microseconds) the client will wait between repeated probes
* to a given server.
*
* @property int $durabilityTimeout
* The time (in microseconds) the client will spend sending repeated probes
* to a given key's vBucket masters and replicas before they are deemed not
* to have satisfied the durability requirements
*
* @see https://developer.couchbase.com/documentation/server/current/sdk/php/start-using-sdk.html
* Start Using SDK
*/
class Bucket
{
/** Ping data (Key/Value) service. */
public const PINGSVC_KV = 0x01;
/** Ping query (N1QL) service. */
public const PINGSVC_N1QL = 0x02;
/** Ping views (Map/Reduce) service. */
public const PINGSVC_VIEWS = 0x04;
/** Ping full text search (FTS) service. */
public const PINGSVC_FTS = 0x08;
final private function __construct() {}
/**
* @param string $name
* @return int
*/
final private function __get($name) {}
/**
* @param string $name
* @param int $value
* @return int
*/
final private function __set($name, $value) {}
/**
* Returns the name of the bucket for current connection
*
* @return string
*/
public function getName() {}
/**
* Returns an instance of a CouchbaseBucketManager for performing management operations against a bucket.
*
* @return BucketManager
*/
public function manager() {}
/**
* Sets custom encoder and decoder functions for handling serialization.
*
* @param callable $encoder
* @param callable $decoder
*
* @see \Couchbase\defaultEncoder
* @see \Couchbase\defaultDecoder
* @see \Couchbase\passthruEncoder
* @see \Couchbase\passthruDecoder
*/
public function setTranscoder($encoder, $decoder) {}
/**
* Retrieves a document
*
* @param string|array $ids one or more IDs
* @param array $options options
* * "lockTime" non zero if the documents have to be locked
* * "expiry" non zero if the expiration time should be updated
* * "groupid" override value for hashing (not recommended to use)
* @return \Couchbase\Document|array document or list of the documents
*
* @see \Couchbase\Bucket::getAndLock()
* @see \Couchbase\Bucket::getAndTouch()
* @see \Couchbase\Bucket::unlock()
* @see \Couchbase\Bucket::touch()
* @see https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html
* Overview of K/V operations
* @see https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html
* More details about K/V operations for PHP SDK
*/
public function get($ids, $options = []) {}
/**
* Retrieves a document and locks it.
*
* After the document has been locked on the server, its CAS would be masked,
* and all mutations of it will be rejected until the server unlocks the document
* automatically or it will be done manually with \Couchbase\Bucket::unlock() operation.
*
* @param string|array $ids one or more IDs
* @param int $lockTime time to lock the documents
* @param array $options options
* * "groupid" override value for hashing (not recommended to use)
* @return \Couchbase\Document|array document or list of the documents
*
* @see \Couchbase\Bucket::unlock()
* @see https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html
* Overview of K/V operations
* @see https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html
* More details about K/V operations for PHP SDK
* @see https://forums.couchbase.com/t/is-there-a-way-to-do-pessimistic-locking-for-more-than-30-seconds/10666/3
* Forum post about getting server defaults for the $lockTime
*/
public function getAndLock($ids, $lockTime, $options = []) {}
/**
* Retrieves a document and updates its expiration time.
*
* @param string|array $ids one or more IDs
* @param int $expiry time after which the document will not be accessible.
* If larger than 30 days (60*60*24*30), it will be interpreted by the
* server as absolute UNIX time (seconds from epoch 1970-01-01T00:00:00).
* @param array $options options
* * "groupid" override value for hashing (not recommended to use)
* @return \Couchbase\Document|array document or list of the documents
*
* @see https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html
* Overview of K/V operations
* @see https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html
* More details about K/V operations for PHP SDK
*/
public function getAndTouch($ids, $expiry, $options = []) {}
/**
* Retrieves a document from a replica.
*
* @param string|array $ids one or more IDs
* @param array $options options
* * "index" the replica index. If the index is zero, it will return
* first successful replica, otherwise it will read only selected node.
* * "groupid" override value for hashing (not recommended to use)
* @return \Couchbase\Document|array document or list of the documents
*
* @see https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html
* Overview of K/V operations
* @see https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html
* More details about K/V operations for PHP SDK
* @see https://developer.couchbase.com/documentation/server/current/sdk/php/failure-considerations.html
* More about failure considerations.
*/
public function getFromReplica($ids, $options = []) {}
/**
* Inserts or updates a document, depending on whether the document already exists on the cluster.
*
* @param string|array $ids one or more IDs
* @param mixed $value value of the document
* @param array $options options
* * "expiry" document expiration time in seconds. If larger than 30 days (60*60*24*30),
* it will be interpreted by the server as absolute UNIX time (seconds from epoch
* 1970-01-01T00:00:00).
* * "persist_to" how many nodes the key should be persisted to (including master).
* If set to 0 then persistence will not be checked. If set to a negative
* number, will be set to the maximum number of nodes to which persistence
* is possible (which will always contain at least the master node).
* * "replicate_to" how many nodes the key should be persisted to (excluding master).
* If set to 0 then replication will not be checked. If set to a negative
* number, will be set to the maximum number of nodes to which replication
* is possible (which may be 0 if the bucket is not configured for replicas).
* * "flags" override flags (not recommended to use)
* * "groupid" override value for hashing (not recommended to use)
* @return \Couchbase\Document|array document or list of the documents
*
* @see https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html
* Overview of K/V operations
* @see https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html
* More details about K/V operations for PHP SDK
*/
public function upsert($ids, $value, $options = []) {}
/**
* Inserts a document. This operation will fail if the document already exists on the cluster.
*
* @param string|array $ids one or more IDs
* @param mixed $value value of the document
* @param array $options options
* * "expiry" document expiration time in seconds. If larger than 30 days (60*60*24*30),
* it will be interpreted by the server as absolute UNIX time (seconds from epoch
* 1970-01-01T00:00:00).
* * "persist_to" how many nodes the key should be persisted to (including master).
* If set to 0 then persistence will not be checked. If set to a negative
* number, will be set to the maximum number of nodes to which persistence
* is possible (which will always contain at least the master node).
* * "replicate_to" how many nodes the key should be persisted to (excluding master).
* If set to 0 then replication will not be checked. If set to a negative
* number, will be set to the maximum number of nodes to which replication
* is possible (which may be 0 if the bucket is not configured for replicas).
* * "flags" override flags (not recommended to use)
* * "groupid" override value for hashing (not recommended to use)
* @return \Couchbase\Document|array document or list of the documents
*
* @see https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html
* Overview of K/V operations
* @see https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html
* More details about K/V operations for PHP SDK
*/
public function insert($ids, $value, $options = []) {}
/**
* Replaces a document. This operation will fail if the document does not exists on the cluster.
*
* @param string|array $ids one or more IDs
* @param mixed $value value of the document
* @param array $options options
* * "cas" last known document CAS, which serves for optimistic locking.
* * "expiry" document expiration time in seconds. If larger than 30 days (60*60*24*30),
* it will be interpreted by the server as absolute UNIX time (seconds from epoch
* 1970-01-01T00:00:00).
* * "persist_to" how many nodes the key should be persisted to (including master).
* If set to 0 then persistence will not be checked. If set to a negative
* number, will be set to the maximum number of nodes to which persistence
* is possible (which will always contain at least the master node).
* * "replicate_to" how many nodes the key should be persisted to (excluding master).
* If set to 0 then replication will not be checked. If set to a negative
* number, will be set to the maximum number of nodes to which replication
* is possible (which may be 0 if the bucket is not configured for replicas).
* * "flags" override flags (not recommended to use)
* * "groupid" override value for hashing (not recommended to use)
* @return \Couchbase\Document|array document or list of the documents
*
* @see https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html
* Overview of K/V operations
* @see https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html
* More details about K/V operations for PHP SDK
*/
public function replace($ids, $value, $options = []) {}
/**
* Appends content to a document.
*
* On the server side it just contatenate passed value to the existing one.
* Note that this might make the value un-decodable. Consider sub-document API
* for partial updates of the JSON documents.
*
* @param string|array $ids one or more IDs
* @param mixed $value value of the document
* @param array $options options
* * "cas" last known document CAS, which serves for optimistic locking.
* * "expiry" document expiration time in seconds. If larger than 30 days (60*60*24*30),
* it will be interpreted by the server as absolute UNIX time (seconds from epoch
* 1970-01-01T00:00:00).
* * "persist_to" how many nodes the key should be persisted to (including master).
* If set to 0 then persistence will not be checked. If set to a negative
* number, will be set to the maximum number of nodes to which persistence
* is possible (which will always contain at least the master node).
* * "replicate_to" how many nodes the key should be persisted to (excluding master).
* If set to 0 then replication will not be checked. If set to a negative
* number, will be set to the maximum number of nodes to which replication
* is possible (which may be 0 if the bucket is not configured for replicas).
* * "groupid" override value for hashing (not recommended to use)
* @return \Couchbase\Document|array document or list of the documents
*
* @see \Couchbase\Bucket::mutateIn()
* @see https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html
* Overview of K/V operations
* @see https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html
* More details about K/V operations for PHP SDK
*/
public function append($ids, $value, $options = []) {}
/**
* Prepends content to a document.
*
* On the server side it just contatenate existing value to the passed one.
* Note that this might make the value un-decodable. Consider sub-document API
* for partial updates of the JSON documents.
*
* @param string|array $ids one or more IDs
* @param mixed $value value of the document
* @param array $options options
* * "cas" last known document CAS, which serves for optimistic locking.
* * "expiry" document expiration time in seconds. If larger than 30 days (60*60*24*30),
* it will be interpreted by the server as absolute UNIX time (seconds from epoch
* 1970-01-01T00:00:00).
* * "persist_to" how many nodes the key should be persisted to (including master).
* If set to 0 then persistence will not be checked. If set to a negative
* number, will be set to the maximum number of nodes to which persistence
* is possible (which will always contain at least the master node).
* * "replicate_to" how many nodes the key should be persisted to (excluding master).
* If set to 0 then replication will not be checked. If set to a negative
* number, will be set to the maximum number of nodes to which replication
* is possible (which may be 0 if the bucket is not configured for replicas).
* * "groupid" override value for hashing (not recommended to use)
* @return \Couchbase\Document|array document or list of the documents
*
* @see \Couchbase\Bucket::mutateIn()
* @see https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html
* Overview of K/V operations
* @see https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html
* More details about K/V operations for PHP SDK
*/
public function prepend($ids, $value, $options = []) {}
/**
* Removes the document.
*
* @param string|array $ids one or more IDs
* @param array $options options
* * "cas" last known document CAS, which serves for optimistic locking.
* * "groupid" override value for hashing (not recommended to use)
* @return \Couchbase\Document|array document or list of the documents
*
* @see https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html
* Overview of K/V operations
* @see https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html
* More details about K/V operations for PHP SDK
*/
public function remove($ids, $options = []) {}
/**
* Unlocks previously locked document
*
* @param string|array $ids one or more IDs
* @param array $options options
* * "cas" last known document CAS, which has been returned by locking command.
* * "groupid" override value for hashing (not recommended to use)
* @return \Couchbase\Document|array document or list of the documents
*
* @see \Couchbase\Bucket::get()
* @see \Couchbase\Bucket::getAndLock()
* @see https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html
* Overview of K/V operations
* @see https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html
* More details about K/V operations for PHP SDK
*/
public function unlock($ids, $options = []) {}
/**
* Updates document's expiration time.
*
* @param string|array $ids one or more IDs
* @param int $expiry time after which the document will not be accessible.
* If larger than 30 days (60*60*24*30), it will be interpreted by the
* server as absolute UNIX time (seconds from epoch 1970-01-01T00:00:00).
* @param array $options options
* * "groupid" override value for hashing (not recommended to use)
* @return \Couchbase\Document|array document or list of the documents
*
* @see https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html
* Overview of K/V operations
* @see https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html
* More details about K/V operations for PHP SDK
*/
public function touch($ids, $expiry, $options = []) {}
/**
* Increments or decrements a key (based on $delta)
*
* @param string|array $ids one or more IDs
* @param int $delta the number whih determines the sign (positive/negative) and the value of the increment
* @param array $options options
* * "initial" initial value of the counter if it does not exist
* * "expiry" time after which the document will not be accessible.
* If larger than 30 days (60*60*24*30), it will be interpreted by the
* server as absolute UNIX time (seconds from epoch 1970-01-01T00:00:00).
* * "groupid" override value for hashing (not recommended to use)
* @return \Couchbase\Document|array document or list of the documents
*
* @see https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html
* Overview of K/V operations
* @see https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html
* More details about K/V operations for PHP SDK
*/
public function counter($ids, $delta = 1, $options = []) {}
/**
* Returns a builder for reading subdocument API.
*
* @param string $id The ID of the JSON document
* @return LookupInBuilder
*
* @see https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html
* Overview of Sub-Document Operations
*/
public function lookupIn($id) {}
/**
* Retrieves specified paths in JSON document
*
* This is essentially a shortcut for `lookupIn($id)->get($paths)->execute()`.
*
* @param string $id The ID of the JSON document
* @param string ...$paths List of the paths inside JSON documents (see "Path syntax" section of the
* "Sub-Document Operations" documentation).
* @return \Couchbase\DocumentFragment
*
* @see https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html
* Overview of Sub-Document Operations
*/
public function retrieveIn($id, ...$paths) {}
/**
* Returns a builder for writing subdocument API.
*
* @param string $id The ID of the JSON document
* @param string $cas Last known document CAS value for optimisti locking
* @return MutateInBuilder
*
* @see https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html
* Overview of Sub-Document Operations
*/
public function mutateIn($id, $cas) {}