Skip to content

Commit ef4e1ca

Browse files
authored
feat(services): add cacache backend (#2548)
* feat(services): add cacache backend Signed-off-by: Chojan Shang <[email protected]> * chore(ci&env): add cacache example Signed-off-by: Chojan Shang <[email protected]> * docs: add cacache Signed-off-by: Chojan Shang <[email protected]> * fix(cacache): map err kind Signed-off-by: Chojan Shang <[email protected]> * fix(cacache): make clippy happy Signed-off-by: Chojan Shang <[email protected]> --------- Signed-off-by: Chojan Shang <[email protected]>
1 parent 8df334f commit ef4e1ca

File tree

14 files changed

+407
-2
lines changed

14 files changed

+407
-2
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,6 @@ OPENDAL_WASABI_SECRET_ACCESS_KEY=<sk>
120120
OPENDAL_REDB_TEST=false
121121
OPENDAL_REDB_DATADIR=/tmp/redb
122122
OPENDAL_REDB_TABLE=redb-table
123+
# cacache
124+
OPENDAL_CACACHE_TEST=false
125+
OPENDAL_CACACHE_DATADIR=/tmp/opendal/cacache/
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: Service Test Cacache
19+
20+
on:
21+
push:
22+
branches:
23+
- main
24+
pull_request:
25+
branches:
26+
- main
27+
paths:
28+
- "core/src/**"
29+
- "core/tests/**"
30+
- "!core/src/docs/**"
31+
- "!core/src/services/**"
32+
- "core/src/services/cacache/**"
33+
- ".github/workflows/service_test_cacache.yml"
34+
35+
concurrency:
36+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
37+
cancel-in-progress: true
38+
39+
jobs:
40+
cacache:
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: actions/checkout@v3
44+
- name: Setup Rust toolchain
45+
uses: ./.github/actions/setup
46+
- name: Test cacache
47+
shell: bash
48+
working-directory: core
49+
run: cargo test cacache --features services-cacache -j=1
50+
env:
51+
RUST_BACKTRACE: full
52+
RUST_LOG: debug
53+
OPENDAL_CACACHE_TEST: on
54+
OPENDAL_CACACHE_DATADIR: /tmp/opendal/cacache/

Cargo.lock

Lines changed: 117 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Major components of the project include:
8181
<details>
8282
<summary>Key-Value Storage Service (like rocksdb, sled)</summary>
8383

84+
- cacache: [cacache](https://crates.io/crates/cacache) backend
8485
- dashmap: [dashmap](https://github.com/xacrimon/dashmap) backend
8586
- memory: In memory backend
8687
- redis: [Redis](https://redis.io/) services

core/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ services-azdfs = [
105105
"reqsign?/services-azblob",
106106
"reqsign?/reqwest_request",
107107
]
108+
services-cacache = ["dep:cacache"]
108109
services-cos = [
109110
"dep:reqsign",
110111
"reqsign?/services-tencent",
@@ -180,6 +181,7 @@ backon = "0.4.0"
180181
base64 = "0.21"
181182
bb8 = { version = "0.8", optional = true }
182183
bytes = "1.2"
184+
cacache = { version = "11.6", default-features = false, features = ["tokio-runtime", "mmap"], optional = true }
183185
chrono = "0.4.24"
184186
dashmap = { version = "5.4", optional = true }
185187
dirs = { version = "5.0.1", optional = true }

core/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
- [azblob](https://docs.rs/opendal/latest/opendal/services/struct.Azblob.html): [Azure Storage Blob](https://azure.microsoft.com/en-us/services/storage/blobs/) services.
2121
- [azdfs](https://docs.rs/opendal/latest/opendal/services/struct.Azdfs.html): [Azure Data Lake Storage Gen2](https://azure.microsoft.com/en-us/products/storage/data-lake-storage/) services. (As known as [abfs](https://learn.microsoft.com/en-us/azure/storage/blobs/data-lake-storage-abfs-driver))
22+
- [cacache](https://docs.rs/opendal/latest/opendal/services/struct.Cacache.html): [cacache](https://crates.io/crates/cacache) backend support.
2223
- [dashmap](https://docs.rs/opendal/latest/opendal/services/struct.Dashmap.html): [dashmap](https://github.com/xacrimon/dashmap) backend support.
2324
- [fs](https://docs.rs/opendal/latest/opendal/services/struct.Fs.html): POSIX alike file system.
2425
- [ftp](https://docs.rs/opendal/latest/opendal/services/struct.Ftp.html): FTP and FTPS support.

0 commit comments

Comments
 (0)