diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-01-05 21:05:40 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-05 21:05:40 +0800 |
commit | 15a475b7dbcf7923d9518dff7764b20e404eb774 (patch) | |
tree | 8789f1f82c5e41345b442df4e58120bdd5f8bade /vendor/github.com/couchbase/gomemcached/client/mc.go | |
parent | 126c9331d6d8789563fae5d5bac2196d63fee0e8 (diff) | |
download | gitea-15a475b7dbcf7923d9518dff7764b20e404eb774.tar.gz gitea-15a475b7dbcf7923d9518dff7764b20e404eb774.zip |
Fix recovery middleware to render gitea style page. (#13857)
* Some changes to fix recovery
* Move Recovery to middlewares
* Remove trace code
* Fix lint
* add session middleware and remove dependent on macaron for sso
* Fix panic 500 page rendering
* Fix bugs
* Fix fmt
* Fix vendor
* recover unnecessary change
* Fix lint and addd some comments about the copied codes.
* Use util.StatDir instead of com.StatDir
Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'vendor/github.com/couchbase/gomemcached/client/mc.go')
-rw-r--r-- | vendor/github.com/couchbase/gomemcached/client/mc.go | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/vendor/github.com/couchbase/gomemcached/client/mc.go b/vendor/github.com/couchbase/gomemcached/client/mc.go index 16dd2f8f7c..208bacdd98 100644 --- a/vendor/github.com/couchbase/gomemcached/client/mc.go +++ b/vendor/github.com/couchbase/gomemcached/client/mc.go @@ -375,6 +375,25 @@ func (c *Client) setCollection(req *gomemcached.MCRequest, context ...*ClientCon return nil } +// Sets collection info in extras +func (c *Client) setExtrasCollection(req *gomemcached.MCRequest, context ...*ClientContext) error { + collectionId := uint32(0) + if len(context) > 0 { + collectionId = context[0].CollId + } + + // if the optional collection is specified, it must be default for clients that haven't turned on collections + if atomic.LoadUint32(&c.collectionsEnabled) == 0 { + if collectionId != 0 { + return fmt.Errorf("Client does not use collections but a collection was specified") + } + } else { + req.Extras = make([]byte, 4) + binary.BigEndian.PutUint32(req.Extras, collectionId) + } + return nil +} + func (c *Client) setVbSeqnoContext(req *gomemcached.MCRequest, context ...*ClientContext) error { if len(context) == 0 || req == nil { return nil @@ -516,9 +535,14 @@ func (c *Client) Del(vb uint16, key string, context ...*ClientContext) (*gomemca // Get a random document func (c *Client) GetRandomDoc(context ...*ClientContext) (*gomemcached.MCResponse, error) { - return c.Send(&gomemcached.MCRequest{ + req := &gomemcached.MCRequest{ Opcode: 0xB6, - }) + } + err := c.setExtrasCollection(req, context...) + if err != nil { + return nil, err + } + return c.Send(req) } // AuthList lists SASL auth mechanisms. |