summaryrefslogtreecommitdiffstats
path: root/vendor/gitea.com/go-chi/cache
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-01-26 23:36:53 +0800
committerGitHub <noreply@github.com>2021-01-26 16:36:53 +0100
commit6433ba0ec3dfde67f45267aa12bd713c4a44c740 (patch)
tree8813388f7e58ff23ad24af9ccbdb5f0350cb3a09 /vendor/gitea.com/go-chi/cache
parent3adbbb4255c42cde04d59b6ebf5ead7e3edda3e7 (diff)
downloadgitea-6433ba0ec3dfde67f45267aa12bd713c4a44c740.tar.gz
gitea-6433ba0ec3dfde67f45267aa12bd713c4a44c740.zip
Move macaron to chi (#14293)
Use [chi](https://github.com/go-chi/chi) instead of the forked [macaron](https://gitea.com/macaron/macaron). Since macaron and chi have conflicts with session share, this big PR becomes a have-to thing. According my previous idea, we can replace macaron step by step but I'm wrong. :( Below is a list of big changes on this PR. - [x] Define `context.ResponseWriter` interface with an implementation `context.Response`. - [x] Use chi instead of macaron, and also a customize `Route` to wrap chi so that the router usage is similar as before. - [x] Create different routers for `web`, `api`, `internal` and `install` so that the codes will be more clear and no magic . - [x] Use https://github.com/unrolled/render instead of macaron's internal render - [x] Use https://github.com/NYTimes/gziphandler instead of https://gitea.com/macaron/gzip - [x] Use https://gitea.com/go-chi/session which is a modified version of https://gitea.com/macaron/session and removed `nodb` support since it will not be maintained. **BREAK** - [x] Use https://gitea.com/go-chi/captcha which is a modified version of https://gitea.com/macaron/captcha - [x] Use https://gitea.com/go-chi/cache which is a modified version of https://gitea.com/macaron/cache - [x] Use https://gitea.com/go-chi/binding which is a modified version of https://gitea.com/macaron/binding - [x] Use https://github.com/go-chi/cors instead of https://gitea.com/macaron/cors - [x] Dropped https://gitea.com/macaron/i18n and make a new one in `code.gitea.io/gitea/modules/translation` - [x] Move validation form structs from `code.gitea.io/gitea/modules/auth` to `code.gitea.io/gitea/modules/forms` to avoid dependency cycle. - [x] Removed macaron log service because it's not need any more. **BREAK** - [x] All form structs have to be get by `web.GetForm(ctx)` in the route function but not as a function parameter on routes definition. - [x] Move Git HTTP protocol implementation to use routers directly. - [x] Fix the problem that chi routes don't support trailing slash but macaron did. - [x] `/api/v1/swagger` now will be redirect to `/api/swagger` but not render directly so that `APIContext` will not create a html render. Notices: - Chi router don't support request with trailing slash - Integration test `TestUserHeatmap` maybe mysql version related. It's failed on my macOS(mysql 5.7.29 installed via brew) but succeed on CI. Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'vendor/gitea.com/go-chi/cache')
-rw-r--r--vendor/gitea.com/go-chi/cache/.drone.yml24
-rw-r--r--vendor/gitea.com/go-chi/cache/.gitignore5
-rw-r--r--vendor/gitea.com/go-chi/cache/LICENSE191
-rw-r--r--vendor/gitea.com/go-chi/cache/README.md20
-rw-r--r--vendor/gitea.com/go-chi/cache/cache.go96
-rw-r--r--vendor/gitea.com/go-chi/cache/file.go207
-rw-r--r--vendor/gitea.com/go-chi/cache/go.mod32
-rw-r--r--vendor/gitea.com/go-chi/cache/go.sum101
-rw-r--r--vendor/gitea.com/go-chi/cache/memcache/memcache.go92
-rw-r--r--vendor/gitea.com/go-chi/cache/memcache/memcache.goconvey1
-rw-r--r--vendor/gitea.com/go-chi/cache/memory.go179
-rw-r--r--vendor/gitea.com/go-chi/cache/utils.go84
12 files changed, 1032 insertions, 0 deletions
diff --git a/vendor/gitea.com/go-chi/cache/.drone.yml b/vendor/gitea.com/go-chi/cache/.drone.yml
new file mode 100644
index 0000000000..9baf4f1cf7
--- /dev/null
+++ b/vendor/gitea.com/go-chi/cache/.drone.yml
@@ -0,0 +1,24 @@
+kind: pipeline
+name: go1-1-1
+
+steps:
+- name: test
+ image: golang:1.11
+ environment:
+ GOPROXY: https://goproxy.cn
+ commands:
+ - go build -v
+ - go test -v -race -coverprofile=coverage.txt -covermode=atomic
+
+---
+kind: pipeline
+name: go1-1-2
+
+steps:
+- name: test
+ image: golang:1.12
+ environment:
+ GOPROXY: https://goproxy.cn
+ commands:
+ - go build -v
+ - go test -v -race -coverprofile=coverage.txt -covermode=atomic \ No newline at end of file
diff --git a/vendor/gitea.com/go-chi/cache/.gitignore b/vendor/gitea.com/go-chi/cache/.gitignore
new file mode 100644
index 0000000000..5c84e85ffc
--- /dev/null
+++ b/vendor/gitea.com/go-chi/cache/.gitignore
@@ -0,0 +1,5 @@
+nodb/cache
+ledis/tmp.db/
+nodb/tmp.db/
+/vendor
+/.idea
diff --git a/vendor/gitea.com/go-chi/cache/LICENSE b/vendor/gitea.com/go-chi/cache/LICENSE
new file mode 100644
index 0000000000..8405e89a0b
--- /dev/null
+++ b/vendor/gitea.com/go-chi/cache/LICENSE
@@ -0,0 +1,191 @@
+Apache License
+Version 2.0, January 2004
+http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction, and
+distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by the copyright
+owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and all other entities
+that control, are controlled by, or are under common control with that entity.
+For the purposes of this definition, "control" means (i) the power, direct or
+indirect, to cause the direction or management of such entity, whether by
+contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
+outstanding shares, or (iii) beneficial ownership of such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity exercising
+permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications, including
+but not limited to software source code, documentation source, and configuration
+files.
+
+"Object" form shall mean any form resulting from mechanical transformation or
+translation of a Source form, including but not limited to compiled object code,
+generated documentation, and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form, made
+available under the License, as indicated by a copyright notice that is included
+in or attached to the work (an example is provided in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form, that
+is based on (or derived from) the Work and for which the editorial revisions,
+annotations, elaborations, or other modifications represent, as a whole, an
+original work of authorship. For the purposes of this License, Derivative Works
+shall not include works that remain separable from, or merely link (or bind by
+name) to the interfaces of, the Work and Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original version
+of the Work and any modifications or additions to that Work or Derivative Works
+thereof, that is intentionally submitted to Licensor for inclusion in the Work
+by the copyright owner or by an individual or Legal Entity authorized to submit
+on behalf of the copyright owner. For the purposes of this definition,
+"submitted" means any form of electronic, verbal, or written communication sent
+to the Licensor or its representatives, including but not limited to
+communication on electronic mailing lists, source code control systems, and
+issue tracking systems that are managed by, or on behalf of, the Licensor for
+the purpose of discussing and improving the Work, but excluding communication
+that is conspicuously marked or otherwise designated in writing by the copyright
+owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
+of whom a Contribution has been received by Licensor and subsequently
+incorporated within the Work.
+
+2. Grant of Copyright License.
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable copyright license to reproduce, prepare Derivative Works of,
+publicly display, publicly perform, sublicense, and distribute the Work and such
+Derivative Works in Source or Object form.
+
+3. Grant of Patent License.
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable (except as stated in this section) patent license to make, have
+made, use, offer to sell, sell, import, and otherwise transfer the Work, where
+such license applies only to those patent claims licensable by such Contributor
+that are necessarily infringed by their Contribution(s) alone or by combination
+of their Contribution(s) with the Work to which such Contribution(s) was
+submitted. If You institute patent litigation against any entity (including a
+cross-claim or counterclaim in a lawsuit) alleging that the Work or a
+Contribution incorporated within the Work constitutes direct or contributory
+patent infringement, then any patent licenses granted to You under this License
+for that Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution.
+
+You may reproduce and distribute copies of the Work or Derivative Works thereof
+in any medium, with or without modifications, and in Source or Object form,
+provided that You meet the following conditions:
+
+You must give any other recipients of the Work or Derivative Works a copy of
+this License; and
+You must cause any modified files to carry prominent notices stating that You
+changed the files; and
+You must retain, in the Source form of any Derivative Works that You distribute,
+all copyright, patent, trademark, and attribution notices from the Source form
+of the Work, excluding those notices that do not pertain to any part of the
+Derivative Works; and
+If the Work includes a "NOTICE" text file as part of its distribution, then any
+Derivative Works that You distribute must include a readable copy of the
+attribution notices contained within such NOTICE file, excluding those notices
+that do not pertain to any part of the Derivative Works, in at least one of the
+following places: within a NOTICE text file distributed as part of the
+Derivative Works; within the Source form or documentation, if provided along
+with the Derivative Works; or, within a display generated by the Derivative
+Works, if and wherever such third-party notices normally appear. The contents of
+the NOTICE file are for informational purposes only and do not modify the
+License. You may add Your own attribution notices within Derivative Works that
+You distribute, alongside or as an addendum to the NOTICE text from the Work,
+provided that such additional attribution notices cannot be construed as
+modifying the License.
+You may add Your own copyright statement to Your modifications and may provide
+additional or different license terms and conditions for use, reproduction, or
+distribution of Your modifications, or for any such Derivative Works as a whole,
+provided Your use, reproduction, and distribution of the Work otherwise complies
+with the conditions stated in this License.
+
+5. Submission of Contributions.
+
+Unless You explicitly state otherwise, any Contribution intentionally submitted
+for inclusion in the Work by You to the Licensor shall be under the terms and
+conditions of this License, without any additional terms or conditions.
+Notwithstanding the above, nothing herein shall supersede or modify the terms of
+any separate license agreement you may have executed with Licensor regarding
+such Contributions.
+
+6. Trademarks.
+
+This License does not grant permission to use the trade names, trademarks,
+service marks, or product names of the Licensor, except as required for
+reasonable and customary use in describing the origin of the Work and
+reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty.
+
+Unless required by applicable law or agreed to in writing, Licensor provides the
+Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
+including, without limitation, any warranties or conditions of TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
+solely responsible for determining the appropriateness of using or
+redistributing the Work and assume any risks associated with Your exercise of
+permissions under this License.
+
+8. Limitation of Liability.
+
+In no event and under no legal theory, whether in tort (including negligence),
+contract, or otherwise, unless required by applicable law (such as deliberate
+and grossly negligent acts) or agreed to in writing, shall any Contributor be
+liable to You for damages, including any direct, indirect, special, incidental,
+or consequential damages of any character arising as a result of this License or
+out of the use or inability to use the Work (including but not limited to
+damages for loss of goodwill, work stoppage, computer failure or malfunction, or
+any and all other commercial damages or losses), even if such Contributor has
+been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability.
+
+While redistributing the Work or Derivative Works thereof, You may choose to
+offer, and charge a fee for, acceptance of support, warranty, indemnity, or
+other liability obligations and/or rights consistent with this License. However,
+in accepting such obligations, You may act only on Your own behalf and on Your
+sole responsibility, not on behalf of any other Contributor, and only if You
+agree to indemnify, defend, and hold each Contributor harmless for any liability
+incurred by, or claims asserted against, such Contributor by reason of your
+accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work
+
+To apply the Apache License to your work, attach the following boilerplate
+notice, with the fields enclosed by brackets "[]" replaced with your own
+identifying information. (Don't include the brackets!) The text should be
+enclosed in the appropriate comment syntax for the file format. We also
+recommend that a file or class name and description of purpose be included on
+the same "printed page" as the copyright notice for easier identification within
+third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. \ No newline at end of file
diff --git a/vendor/gitea.com/go-chi/cache/README.md b/vendor/gitea.com/go-chi/cache/README.md
new file mode 100644
index 0000000000..e9eac96115
--- /dev/null
+++ b/vendor/gitea.com/go-chi/cache/README.md
@@ -0,0 +1,20 @@
+# cache
+
+Middleware cache provides cache management for [Macaron](https://github.com/go-macaron/macaron). It can use many cache adapters, including memory, file, Redis, Memcache, PostgreSQL, MySQL, Ledis and Nodb.
+
+### Installation
+
+ go get gitea.com/macaron/cache
+
+## Getting Help
+
+- [API Reference](https://gowalker.org/gitea.com/macaron/cache)
+- [Documentation](http://go-macaron.com/docs/middlewares/cache)
+
+## Credits
+
+This package is a modified version of [go-macaron/cache](github.com/go-macaron/cache).
+
+## License
+
+This project is under the Apache License, Version 2.0. See the [LICENSE](LICENSE) file for the full license text. \ No newline at end of file
diff --git a/vendor/gitea.com/go-chi/cache/cache.go b/vendor/gitea.com/go-chi/cache/cache.go
new file mode 100644
index 0000000000..79d92cc6d8
--- /dev/null
+++ b/vendor/gitea.com/go-chi/cache/cache.go
@@ -0,0 +1,96 @@
+// Copyright 2013 Beego Authors
+// Copyright 2014 The Macaron Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+// Package cache is a middleware that provides the cache management of Macaron.
+package cache
+
+import (
+ "fmt"
+)
+
+// Cache is the interface that operates the cache data.
+type Cache interface {
+ // Put puts value into cache with key and expire time.
+ Put(key string, val interface{}, timeout int64) error
+ // Get gets cached value by given key.
+ Get(key string) interface{}
+ // Delete deletes cached value by given key.
+ Delete(key string) error
+ // Incr increases cached int-type value by given key as a counter.
+ Incr(key string) error
+ // Decr decreases cached int-type value by given key as a counter.
+ Decr(key string) error
+ // IsExist returns true if cached value exists.
+ IsExist(key string) bool
+ // Flush deletes all cached data.
+ Flush() error
+ // StartAndGC starts GC routine based on config string settings.
+ StartAndGC(opt Options) error
+}
+
+// Options represents a struct for specifying configuration options for the cache middleware.
+type Options struct {
+ // Name of adapter. Default is "memory".
+ Adapter string
+ // Adapter configuration, it's corresponding to adapter.
+ AdapterConfig string
+ // GC interval time in seconds. Default is 60.
+ Interval int
+ // Occupy entire database. Default is false.
+ OccupyMode bool
+ // Configuration section name. Default is "cache".
+ Section string
+}
+
+func prepareOptions(opt Options) Options {
+ if len(opt.Section) == 0 {
+ opt.Section = "cache"
+ }
+ if len(opt.Adapter) == 0 {
+ opt.Adapter = "memory"
+ }
+ if opt.Interval == 0 {
+ opt.Interval = 60
+ }
+ if len(opt.AdapterConfig) == 0 {
+ opt.AdapterConfig = "data/caches"
+ }
+
+ return opt
+}
+
+// NewCacher creates and returns a new cacher by given adapter name and configuration.
+// It panics when given adapter isn't registered and starts GC automatically.
+func NewCacher(opt Options) (Cache, error) {
+ opt = prepareOptions(opt)
+ adapter, ok := adapters[opt.Adapter]
+ if !ok {
+ return nil, fmt.Errorf("cache: unknown adapter '%s'(forgot to import?)", opt.Adapter)
+ }
+ return adapter, adapter.StartAndGC(opt)
+}
+
+var adapters = make(map[string]Cache)
+
+// Register registers a adapter.
+func Register(name string, adapter Cache) {
+ if adapter == nil {
+ panic("cache: cannot register adapter with nil value")
+ }
+ if _, dup := adapters[name]; dup {
+ panic(fmt.Errorf("cache: cannot register adapter '%s' twice", name))
+ }
+ adapters[name] = adapter
+}
diff --git a/vendor/gitea.com/go-chi/cache/file.go b/vendor/gitea.com/go-chi/cache/file.go
new file mode 100644
index 0000000000..d07ab0b11e
--- /dev/null
+++ b/vendor/gitea.com/go-chi/cache/file.go
@@ -0,0 +1,207 @@
+// Copyright 2013 Beego Authors
+// Copyright 2014 The Macaron Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+package cache
+
+import (
+ "crypto/md5"
+ "encoding/hex"
+ "fmt"
+ "io/ioutil"
+ "log"
+ "os"
+ "path/filepath"
+ "sync"
+ "time"
+
+ "github.com/unknwon/com"
+)
+
+// Item represents a cache item.
+type Item struct {
+ Val interface{}
+ Created int64
+ Expire int64
+}
+
+func (item *Item) hasExpired() bool {
+ return item.Expire > 0 &&
+ (time.Now().Unix()-item.Created) >= item.Expire
+}
+
+// FileCacher represents a file cache adapter implementation.
+type FileCacher struct {
+ lock sync.Mutex
+ rootPath string
+ interval int // GC interval.
+}
+
+// NewFileCacher creates and returns a new file cacher.
+func NewFileCacher() *FileCacher {
+ return &FileCacher{}
+}
+
+func (c *FileCacher) filepath(key string) string {
+ m := md5.Sum([]byte(key))
+ hash := hex.EncodeToString(m[:])
+ return filepath.Join(c.rootPath, string(hash[0]), string(hash[1]), hash)
+}
+
+// Put puts value into cache with key and expire time.
+// If expired is 0, it will be deleted by next GC operation.
+func (c *FileCacher) Put(key string, val interface{}, expire int64) error {
+ filename := c.filepath(key)
+ item := &Item{val, time.Now().Unix(), expire}
+ data, err := EncodeGob(item)
+ if err != nil {
+ return err
+ }
+
+ os.MkdirAll(filepath.Dir(filename), os.ModePerm)
+ return ioutil.WriteFile(filename, data, os.ModePerm)
+}
+
+func (c *FileCacher) read(key string) (*Item, error) {
+ filename := c.filepath(key)
+
+ data, err := ioutil.ReadFile(filename)
+ if err != nil {
+ return nil, err
+ }
+
+ item := new(Item)
+ return item, DecodeGob(data, item)
+}
+
+// Get gets cached value by given key.
+func (c *FileCacher) Get(key string) interface{} {
+ item, err := c.read(key)
+ if err != nil {
+ return nil
+ }
+
+ if item.hasExpired() {
+ os.Remove(c.filepath(key))
+ return nil
+ }
+ return item.Val
+}
+
+// Delete deletes cached value by given key.
+func (c *FileCacher) Delete(key string) error {
+ return os.Remove(c.filepath(key))
+}
+
+// Incr increases cached int-type value by given key as a counter.
+func (c *FileCacher) Incr(key string) error {
+ item, err := c.read(key)
+ if err != nil {
+ return err
+ }
+
+ item.Val, err = Incr(item.Val)
+ if err != nil {
+ return err
+ }
+
+ return c.Put(key, item.Val, item.Expire)
+}
+
+// Decrease cached int value.
+func (c *FileCacher) Decr(key string) error {
+ item, err := c.read(key)
+ if err != nil {
+ return err
+ }
+
+ item.Val, err = Decr(item.Val)
+ if err != nil {
+ return err
+ }
+
+ return c.Put(key, item.Val, item.Expire)
+}
+
+// IsExist returns true if cached value exists.
+func (c *FileCacher) IsExist(key string) bool {
+ return com.IsExist(c.filepath(key))
+}
+
+// Flush deletes all cached data.
+func (c *FileCacher) Flush() error {
+ return os.RemoveAll(c.rootPath)
+}
+
+func (c *FileCacher) startGC() {
+ c.lock.Lock()
+ defer c.lock.Unlock()
+
+ if c.interval < 1 {
+ return
+ }
+
+ if err := filepath.Walk(c.rootPath, func(path string, fi os.FileInfo, err error) error {
+ if err != nil {
+ return fmt.Errorf("Walk: %v", err)
+ }
+
+ if fi.IsDir() {
+ return nil
+ }
+
+ data, err := ioutil.ReadFile(path)
+ if err != nil && !os.IsNotExist(err) {
+ fmt.Errorf("ReadFile: %v", err)
+ }
+
+ item := new(Item)
+ if err = DecodeGob(data, item); err != nil {
+ return err
+ }
+ if item.hasExpired() {
+ if err = os.Remove(path); err != nil && !os.IsNotExist(err) {
+ return fmt.Errorf("Remove: %v", err)
+ }
+ }
+ return nil
+ }); err != nil {
+ log.Printf("error garbage collecting cache files: %v", err)
+ }
+
+ time.AfterFunc(time.Duration(c.interval)*time.Second, func() { c.startGC() })
+}
+
+// StartAndGC starts GC routine based on config string settings.
+func (c *FileCacher) StartAndGC(opt Options) error {
+ c.lock.Lock()
+ c.rootPath = opt.AdapterConfig
+ c.interval = opt.Interval
+
+ if !filepath.IsAbs(c.rootPath) {
+ panic("rootPath must be an absolute path")
+ }
+ c.lock.Unlock()
+
+ if err := os.MkdirAll(c.rootPath, os.ModePerm); err != nil {
+ return err
+ }
+
+ go c.startGC()
+ return nil
+}
+
+func init() {
+ Register("file", NewFileCacher())
+}
diff --git a/vendor/gitea.com/go-chi/cache/go.mod b/vendor/gitea.com/go-chi/cache/go.mod
new file mode 100644
index 0000000000..3609e210bd
--- /dev/null
+++ b/vendor/gitea.com/go-chi/cache/go.mod
@@ -0,0 +1,32 @@
+module gitea.com/go-chi/cache
+
+go 1.11
+
+require (
+ github.com/BurntSushi/toml v0.3.1 // indirect
+ github.com/bradfitz/gomemcache v0.0.0-20190329173943-551aad21a668
+ github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76 // indirect
+ github.com/edsrzf/mmap-go v1.0.0 // indirect
+ github.com/go-redis/redis v6.15.2+incompatible
+ github.com/go-sql-driver/mysql v1.4.1
+ github.com/golang/snappy v0.0.2 // indirect
+ github.com/lib/pq v1.2.0
+ github.com/lunny/log v0.0.0-20160921050905-7887c61bf0de // indirect
+ github.com/lunny/nodb v0.0.0-20160621015157-fc1ef06ad4af
+ github.com/mattn/go-sqlite3 v1.11.0 // indirect
+ github.com/onsi/ginkgo v1.8.0 // indirect
+ github.com/onsi/gomega v1.5.0 // indirect
+ github.com/pelletier/go-toml v1.8.1 // indirect
+ github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726 // indirect
+ github.com/siddontang/go-snappy v0.0.0-20140704025258-d8f7bb82a96d // indirect
+ github.com/siddontang/ledisdb v0.0.0-20190202134119-8ceb77e66a92
+ github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d // indirect
+ github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337
+ github.com/syndtr/goleveldb v1.0.0 // indirect
+ github.com/unknwon/com v0.0.0-20190804042917-757f69c95f3e
+ golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 // indirect
+ golang.org/x/sys v0.0.0-20190730183949-1393eb018365 // indirect
+ google.golang.org/appengine v1.6.1 // indirect
+ gopkg.in/ini.v1 v1.44.2
+ gopkg.in/yaml.v2 v2.2.2 // indirect
+)
diff --git a/vendor/gitea.com/go-chi/cache/go.sum b/vendor/gitea.com/go-chi/cache/go.sum
new file mode 100644
index 0000000000..8ed30d7a7a
--- /dev/null
+++ b/vendor/gitea.com/go-chi/cache/go.sum
@@ -0,0 +1,101 @@
+github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
+github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
+github.com/bradfitz/gomemcache v0.0.0-20190329173943-551aad21a668 h1:U/lr3Dgy4WK+hNk4tyD+nuGjpVLPEHuJSFXMw11/HPA=
+github.com/bradfitz/gomemcache v0.0.0-20190329173943-551aad21a668/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA=
+github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76 h1:Lgdd/Qp96Qj8jqLpq2cI1I1X7BJnu06efS+XkhRoLUQ=
+github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw=
+github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
+github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
+github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
+github.com/go-redis/redis v6.15.2+incompatible h1:9SpNVG76gr6InJGxoZ6IuuxaCOQwDAhzyXg+Bs+0Sb4=
+github.com/go-redis/redis v6.15.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
+github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
+github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
+github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
+github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w=
+github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
+github.com/golang/snappy v0.0.2 h1:aeE13tS0IiQgFjYdoL8qN3K1N2bXXtI6Vi51/y7BpMw=
+github.com/golang/snappy v0.0.2/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
+github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
+github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e h1:JKmoR8x90Iww1ks85zJ1lfDGgIiMDuIptTOhJq+zKyg=
+github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
+github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
+github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
+github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
+github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
+github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
+github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0=
+github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
+github.com/lunny/log v0.0.0-20160921050905-7887c61bf0de h1:nyxwRdWHAVxpFcDThedEgQ07DbcRc5xgNObtbTp76fk=
+github.com/lunny/log v0.0.0-20160921050905-7887c61bf0de/go.mod h1:3q8WtuPQsoRbatJuy3nvq/hRSvuBJrHHr+ybPPiNvHQ=
+github.com/lunny/nodb v0.0.0-20160621015157-fc1ef06ad4af h1:UaWHNBdukWrSG3DRvHFR/hyfg681fceqQDYVTBncKfQ=
+github.com/lunny/nodb v0.0.0-20160621015157-fc1ef06ad4af/go.mod h1:Cqz6pqow14VObJ7peltM+2n3PWOz7yTrfUuGbVFkzN0=
+github.com/mattn/go-sqlite3 v1.11.0 h1:LDdKkqtYlom37fkvqs8rMPFKAMe8+SgjbwZ6ex1/A/Q=
+github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
+github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w=
+github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
+github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo=
+github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
+github.com/pelletier/go-toml v1.8.1 h1:1Nf83orprkJyknT6h7zbuEGUEjcyVlCxSUGTENmNCRM=
+github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
+github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726 h1:xT+JlYxNGqyT+XcU8iUrN18JYed2TvG9yN5ULG2jATM=
+github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
+github.com/siddontang/go-snappy v0.0.0-20140704025258-d8f7bb82a96d h1:qQWKKOvHN7Q9c6GdmUteCef2F9ubxMpxY1IKwpIKz68=
+github.com/siddontang/go-snappy v0.0.0-20140704025258-d8f7bb82a96d/go.mod h1:vq0tzqLRu6TS7Id0wMo2N5QzJoKedVeovOpHjnykSzY=
+github.com/siddontang/ledisdb v0.0.0-20190202134119-8ceb77e66a92 h1:qvsJwGToa8rxb42cDRhkbKeX2H5N8BH+s2aUikGt8mI=
+github.com/siddontang/ledisdb v0.0.0-20190202134119-8ceb77e66a92/go.mod h1:mF1DpOSOUiJRMR+FDqaqu3EBqrybQtrDDszLUZ6oxPg=
+github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d h1:NVwnfyR3rENtlz62bcrkXME3INVUa4lcdGt+opvxExs=
+github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=
+github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
+github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304 h1:Jpy1PXuP99tXNrhbq2BaPz9B+jNAvH1JPQQpG/9GCXY=
+github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
+github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s=
+github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 h1:WN9BUFbdyOsSH/XohnWpXOlq9NBD5sGAB2FciQMUEe8=
+github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
+github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
+github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
+github.com/unknwon/com v0.0.0-20190804042917-757f69c95f3e h1:GSGeB9EAKY2spCABz6xOX5DbxZEXolK+nBSvmsQwRjM=
+github.com/unknwon/com v0.0.0-20190804042917-757f69c95f3e/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
+golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 h1:Ao/3l156eZf2AW5wK8a7/smtodRU+gha3+BeqJ69lRk=
+golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190730183949-1393eb018365 h1:SaXEMXhWzMJThc05vu6uh61Q245r4KaWMrsTedk0FDc=
+golang.org/x/sys v0.0.0-20190730183949-1393eb018365/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
+golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+google.golang.org/appengine v1.6.1 h1:QzqyMA1tlu6CgqCDUtU9V+ZKhLFT2dkJuANu5QaxI3I=
+google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
+gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
+gopkg.in/ini.v1 v1.44.2 h1:N6kNUPqiIyxP+s/aINPzRvNpcTVV30qLC0t6ZjZFlUU=
+gopkg.in/ini.v1 v1.44.2/go.mod h1:M3Cogqpuv0QCi3ExAY5V4uOt4qb/R3xZubo9m8lK5wg=
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
+gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/vendor/gitea.com/go-chi/cache/memcache/memcache.go b/vendor/gitea.com/go-chi/cache/memcache/memcache.go
new file mode 100644
index 0000000000..400a774569
--- /dev/null
+++ b/vendor/gitea.com/go-chi/cache/memcache/memcache.go
@@ -0,0 +1,92 @@
+// Copyright 2013 Beego Authors
+// Copyright 2014 The Macaron Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+package cache
+
+import (
+ "strings"
+
+ "github.com/bradfitz/gomemcache/memcache"
+ "github.com/unknwon/com"
+
+ "gitea.com/go-chi/cache"
+)
+
+// MemcacheCacher represents a memcache cache adapter implementation.
+type MemcacheCacher struct {
+ c *memcache.Client
+}
+
+func NewItem(key string, data []byte, expire int32) *memcache.Item {
+ return &memcache.Item{
+ Key: key,
+ Value: data,
+ Expiration: expire,
+ }
+}
+
+// Put puts value into cache with key and expire time.
+// If expired is 0, it lives forever.
+func (c *MemcacheCacher) Put(key string, val interface{}, expire int64) error {
+ return c.c.Set(NewItem(key, []byte(com.ToStr(val)), int32(expire)))
+}
+
+// Get gets cached value by given key.
+func (c *MemcacheCacher) Get(key string) interface{} {
+ item, err := c.c.Get(key)
+ if err != nil {
+ return nil
+ }
+ return string(item.Value)
+}
+
+// Delete deletes cached value by given key.
+func (c *MemcacheCacher) Delete(key string) error {
+ return c.c.Delete(key)
+}
+
+// Incr increases cached int-type value by given key as a counter.
+func (c *MemcacheCacher) Incr(key string) error {
+ _, err := c.c.Increment(key, 1)
+ return err
+}
+
+// Decr decreases cached int-type value by given key as a counter.
+func (c *MemcacheCacher) Decr(key string) error {
+ _, err := c.c.Decrement(key, 1)
+ return err
+}
+
+// IsExist returns true if cached value exists.
+func (c *MemcacheCacher) IsExist(key string) bool {
+ _, err := c.c.Get(key)
+ return err == nil
+}
+
+// Flush deletes all cached data.
+func (c *MemcacheCacher) Flush() error {
+ return c.c.FlushAll()
+}
+
+// StartAndGC starts GC routine based on config string settings.
+// AdapterConfig: 127.0.0.1:9090;127.0.0.1:9091
+func (c *MemcacheCacher) StartAndGC(opt cache.Options) error {
+ c.c = memcache.New(strings.Split(opt.AdapterConfig, ";")...)
+ return nil
+}
+
+func init() {
+ cache.Register("memcache", &MemcacheCacher{})
+}
diff --git a/vendor/gitea.com/go-chi/cache/memcache/memcache.goconvey b/vendor/gitea.com/go-chi/cache/memcache/memcache.goconvey
new file mode 100644
index 0000000000..8485e986e4
--- /dev/null
+++ b/vendor/gitea.com/go-chi/cache/memcache/memcache.goconvey
@@ -0,0 +1 @@
+ignore \ No newline at end of file
diff --git a/vendor/gitea.com/go-chi/cache/memory.go b/vendor/gitea.com/go-chi/cache/memory.go
new file mode 100644
index 0000000000..2d5a8fac4d
--- /dev/null
+++ b/vendor/gitea.com/go-chi/cache/memory.go
@@ -0,0 +1,179 @@
+// Copyright 2013 Beego Authors
+// Copyright 2014 The Macaron Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+package cache
+
+import (
+ "errors"
+ "sync"
+ "time"
+)
+
+// MemoryItem represents a memory cache item.
+type MemoryItem struct {
+ val interface{}
+ created int64
+ expire int64
+}
+
+func (item *MemoryItem) hasExpired() bool {
+ return item.expire > 0 &&
+ (time.Now().Unix()-item.created) >= item.expire
+}
+
+// MemoryCacher represents a memory cache adapter implementation.
+type MemoryCacher struct {
+ lock sync.RWMutex
+ items map[string]*MemoryItem
+ interval int // GC interval.
+}
+
+// NewMemoryCacher creates and returns a new memory cacher.
+func NewMemoryCacher() *MemoryCacher {
+ return &MemoryCacher{items: make(map[string]*MemoryItem)}
+}
+
+// Put puts value into cache with key and expire time.
+// If expired is 0, it will be deleted by next GC operation.
+func (c *MemoryCacher) Put(key string, val interface{}, expire int64) error {
+ c.lock.Lock()
+ defer c.lock.Unlock()
+
+ c.items[key] = &MemoryItem{
+ val: val,
+ created: time.Now().Unix(),
+ expire: expire,
+ }
+ return nil
+}
+
+// Get gets cached value by given key.
+func (c *MemoryCacher) Get(key string) interface{} {
+ c.lock.RLock()
+ defer c.lock.RUnlock()
+
+ item, ok := c.items[key]
+ if !ok {
+ return nil
+ }
+ if item.hasExpired() {
+ go c.Delete(key)
+ return nil
+ }
+ return item.val
+}
+
+// Delete deletes cached value by given key.
+func (c *MemoryCacher) Delete(key string) error {
+ c.lock.Lock()
+ defer c.lock.Unlock()
+
+ delete(c.items, key)
+ return nil
+}
+
+// Incr increases cached int-type value by given key as a counter.
+func (c *MemoryCacher) Incr(key string) (err error) {
+ c.lock.RLock()
+ defer c.lock.RUnlock()
+
+ item, ok := c.items[key]
+ if !ok {
+ return errors.New("key not exist")
+ }
+ item.val, err = Incr(item.val)
+ return err
+}
+
+// Decr decreases cached int-type value by given key as a counter.
+func (c *MemoryCacher) Decr(key string) (err error) {
+ c.lock.RLock()
+ defer c.lock.RUnlock()
+
+ item, ok := c.items[key]
+ if !ok {
+ return errors.New("key not exist")
+ }
+
+ item.val, err = Decr(item.val)
+ return err
+}
+
+// IsExist returns true if cached value exists.
+func (c *MemoryCacher) IsExist(key string) bool {
+ c.lock.RLock()
+ defer c.lock.RUnlock()
+
+ _, ok := c.items[key]
+ return ok
+}
+
+// Flush deletes all cached data.
+func (c *MemoryCacher) Flush() error {
+ c.lock.Lock()
+ defer c.lock.Unlock()
+
+ c.items = make(map[string]*MemoryItem)
+ return nil
+}
+
+func (c *MemoryCacher) checkRawExpiration(key string) {
+ item, ok := c.items[key]
+ if !ok {
+ return
+ }
+
+ if item.hasExpired() {
+ delete(c.items, key)
+ }
+}
+
+func (c *MemoryCacher) checkExpiration(key string) {
+ c.lock.Lock()
+ defer c.lock.Unlock()
+
+ c.checkRawExpiration(key)
+}
+
+func (c *MemoryCacher) startGC() {
+ c.lock.Lock()
+ defer c.lock.Unlock()
+
+ if c.interval < 1 {
+ return
+ }
+
+ if c.items != nil {
+ for key, _ := range c.items {
+ c.checkRawExpiration(key)
+ }
+ }
+
+ time.AfterFunc(time.Duration(c.interval)*time.Second, func() { c.startGC() })
+}
+
+// StartAndGC starts GC routine based on config string settings.
+func (c *MemoryCacher) StartAndGC(opt Options) error {
+ c.lock.Lock()
+ c.interval = opt.Interval
+ c.lock.Unlock()
+
+ go c.startGC()
+ return nil
+}
+
+func init() {
+ Register("memory", NewMemoryCacher())
+}
diff --git a/vendor/gitea.com/go-chi/cache/utils.go b/vendor/gitea.com/go-chi/cache/utils.go
new file mode 100644
index 0000000000..734fb6f40e
--- /dev/null
+++ b/vendor/gitea.com/go-chi/cache/utils.go
@@ -0,0 +1,84 @@
+// Copyright 2014 The Macaron Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+package cache
+
+import (
+ "bytes"
+ "encoding/gob"
+ "errors"
+)
+
+func EncodeGob(item *Item) ([]byte, error) {
+ buf := bytes.NewBuffer(nil)
+ err := gob.NewEncoder(buf).Encode(item)
+ return buf.Bytes(), err
+}
+
+func DecodeGob(data []byte, out *Item) error {
+ buf := bytes.NewBuffer(data)
+ return gob.NewDecoder(buf).Decode(&out)
+}
+
+func Incr(val interface{}) (interface{}, error) {
+ switch val.(type) {
+ case int:
+ val = val.(int) + 1
+ case int32:
+ val = val.(int32) + 1
+ case int64:
+ val = val.(int64) + 1
+ case uint:
+ val = val.(uint) + 1
+ case uint32:
+ val = val.(uint32) + 1
+ case uint64:
+ val = val.(uint64) + 1
+ default:
+ return val, errors.New("item value is not int-type")
+ }
+ return val, nil
+}
+
+func Decr(val interface{}) (interface{}, error) {
+ switch val.(type) {
+ case int:
+ val = val.(int) - 1
+ case int32:
+ val = val.(int32) - 1
+ case int64:
+ val = val.(int64) - 1
+ case uint:
+ if val.(uint) > 0 {
+ val = val.(uint) - 1
+ } else {
+ return val, errors.New("item value is less than 0")
+ }
+ case uint32:
+ if val.(uint32) > 0 {
+ val = val.(uint32) - 1
+ } else {
+ return val, errors.New("item value is less than 0")
+ }
+ case uint64:
+ if val.(uint64) > 0 {
+ val = val.(uint64) - 1
+ } else {
+ return val, errors.New("item value is less than 0")
+ }
+ default:
+ return val, errors.New("item value is not int-type")
+ }
+ return val, nil
+}