cachebox 6.2.0__tar.gz → 6.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cachebox-6.2.0 → cachebox-6.2.1}/.github/workflows/CI.yml +4 -6
- {cachebox-6.2.0 → cachebox-6.2.1}/.github/workflows/python-test.yml +12 -9
- {cachebox-6.2.0 → cachebox-6.2.1}/Cargo.lock +8 -1
- {cachebox-6.2.0 → cachebox-6.2.1}/Cargo.toml +2 -2
- {cachebox-6.2.0 → cachebox-6.2.1}/PKG-INFO +1 -1
- {cachebox-6.2.0 → cachebox-6.2.1}/requirements-dev.txt +1 -0
- cachebox-6.2.1/src/hashbrown/alloc.rs +21 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/hashbrown/raw.rs +4 -5
- cachebox-6.2.1/src/hashbrown/util.rs +23 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/internal/lazyheap.rs +1 -1
- {cachebox-6.2.0 → cachebox-6.2.1}/src/internal/linked_list.rs +1 -1
- {cachebox-6.2.0 → cachebox-6.2.1}/src/internal/onceinit.rs +1 -1
- {cachebox-6.2.0 → cachebox-6.2.1}/src/internal/utils.rs +1 -1
- {cachebox-6.2.0 → cachebox-6.2.1}/src/lib.rs +4 -8
- {cachebox-6.2.0 → cachebox-6.2.1}/src/policies/fifopolicy.rs +2 -1
- {cachebox-6.2.0 → cachebox-6.2.1}/src/policies/ttlpolicy.rs +4 -7
- {cachebox-6.2.0 → cachebox-6.2.1}/tests/test_utils.py +3 -3
- cachebox-6.2.0/src/hashbrown/alloc.rs +0 -13
- cachebox-6.2.0/src/hashbrown/util.rs +0 -9
- {cachebox-6.2.0 → cachebox-6.2.1}/.github/workflows/docs.yml +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/.gitignore +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/LICENSE +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/LICENSE-THIRD-PARTY +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/README.md +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/build.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/cachebox/__init__.py +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/cachebox/_cachebox.py +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/cachebox/_core.pyi +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/cachebox/_wrappers.py +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/cachebox/utils.py +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/docs/docs/api/impls.md +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/docs/docs/api/index.md +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/docs/docs/api/utils.md +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/docs/docs/getting-started.md +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/docs/docs/index.md +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/docs/docs/installation.md +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/docs/docs/migration.md +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/docs/docs/tips.md +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/docs/mkdocs.yml +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/pyproject.toml +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/rustfmt.toml +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/hashbrown/control/bitmask.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/hashbrown/control/group/generic.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/hashbrown/control/group/lsx.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/hashbrown/control/group/mod.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/hashbrown/control/group/neon.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/hashbrown/control/group/sse2.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/hashbrown/control/mod.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/hashbrown/control/tag.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/hashbrown/mod.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/hashbrown/scopeguard.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/internal/alias.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/internal/mod.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/internal/pickle.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/macro_rules.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/policies/common.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/policies/lfupolicy.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/policies/lrupolicy.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/policies/mod.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/policies/nopolicy.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/policies/rrpolicy.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/policies/traits.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/policies/vttlpolicy.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/policies/wrapped.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/pyclasses/base.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/pyclasses/cache.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/pyclasses/fifocache.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/pyclasses/lfucache.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/pyclasses/lrucache.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/pyclasses/mod.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/pyclasses/rrcache.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/pyclasses/ttlcache.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/pyclasses/vttlcache.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/src/typeref.rs +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/tests/__init__.py +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/tests/conftest.py +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/tests/mixins.py +0 -0
- {cachebox-6.2.0 → cachebox-6.2.1}/tests/test_impls.py +0 -0
|
@@ -57,7 +57,6 @@ jobs:
|
|
|
57
57
|
args: --release --out dist --interpreter ${{ matrix.platform.interpreter }}
|
|
58
58
|
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
59
59
|
manylinux: auto
|
|
60
|
-
rust-toolchain: nightly
|
|
61
60
|
|
|
62
61
|
- uses: actions/upload-artifact@v7.0.1
|
|
63
62
|
with:
|
|
@@ -101,7 +100,6 @@ jobs:
|
|
|
101
100
|
args: --release --out dist --interpreter ${{ matrix.platform.interpreter }}
|
|
102
101
|
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
103
102
|
manylinux: musllinux_1_2
|
|
104
|
-
rust-toolchain: nightly
|
|
105
103
|
|
|
106
104
|
- uses: actions/upload-artifact@v7.0.1
|
|
107
105
|
with:
|
|
@@ -117,7 +115,10 @@ jobs:
|
|
|
117
115
|
target: x64,
|
|
118
116
|
interpreter: "3.10 3.11 3.12 3.13 3.14 3.14t 3.15 3.15t pypy3.11",
|
|
119
117
|
}
|
|
120
|
-
- {
|
|
118
|
+
- {
|
|
119
|
+
target: x86,
|
|
120
|
+
interpreter: "3.10 3.11 3.12 3.13 3.14 3.14t 3.15 3.15t",
|
|
121
|
+
}
|
|
121
122
|
|
|
122
123
|
steps:
|
|
123
124
|
- uses: actions/checkout@v6.0.2
|
|
@@ -134,7 +135,6 @@ jobs:
|
|
|
134
135
|
target: ${{ matrix.platform.target }}
|
|
135
136
|
args: --release --out dist --interpreter ${{ matrix.platform.interpreter }}
|
|
136
137
|
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
137
|
-
rust-toolchain: nightly
|
|
138
138
|
|
|
139
139
|
- uses: actions/upload-artifact@v7.0.1
|
|
140
140
|
with:
|
|
@@ -169,7 +169,6 @@ jobs:
|
|
|
169
169
|
target: ${{ matrix.platform.target }}
|
|
170
170
|
args: --release --out dist --interpreter ${{ matrix.platform.interpreter }}
|
|
171
171
|
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
172
|
-
rust-toolchain: nightly
|
|
173
172
|
|
|
174
173
|
- uses: actions/upload-artifact@v7.0.1
|
|
175
174
|
with:
|
|
@@ -188,7 +187,6 @@ jobs:
|
|
|
188
187
|
with:
|
|
189
188
|
command: sdist
|
|
190
189
|
args: --out dist
|
|
191
|
-
rust-toolchain: nightly
|
|
192
190
|
|
|
193
191
|
- name: Upload sdist
|
|
194
192
|
uses: actions/upload-artifact@v7.0.1
|
|
@@ -16,7 +16,7 @@ env:
|
|
|
16
16
|
|
|
17
17
|
jobs:
|
|
18
18
|
test-python:
|
|
19
|
-
name:
|
|
19
|
+
name: ${{ matrix.python-version }}
|
|
20
20
|
runs-on: ubuntu-latest
|
|
21
21
|
continue-on-error: ${{ endsWith(matrix.python-version, 't') }}
|
|
22
22
|
strategy:
|
|
@@ -36,22 +36,24 @@ jobs:
|
|
|
36
36
|
steps:
|
|
37
37
|
- uses: actions/checkout@v6.0.2
|
|
38
38
|
|
|
39
|
-
- uses: dtolnay/rust-toolchain@
|
|
39
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
40
40
|
|
|
41
41
|
- uses: actions/setup-python@v6.2.0
|
|
42
42
|
with:
|
|
43
43
|
python-version: ${{ matrix.python-version }}
|
|
44
44
|
allow-prereleases: true
|
|
45
45
|
|
|
46
|
-
- run: pip install virtualenv
|
|
46
|
+
- run: pip install virtualenv
|
|
47
|
+
- run: pip install -r requirements-dev.txt
|
|
47
48
|
- run: virtualenv --no-vcs-ignore .venv
|
|
49
|
+
|
|
48
50
|
- run: maturin develop --features use-small-offset
|
|
49
|
-
- run: pytest -v
|
|
51
|
+
- run: pytest -v -n auto
|
|
50
52
|
env:
|
|
51
53
|
HYPOTHESIS_PROFILE: slow
|
|
52
54
|
|
|
53
55
|
test-os:
|
|
54
|
-
name:
|
|
56
|
+
name: ${{ matrix.os }}
|
|
55
57
|
runs-on: ${{ matrix.os }}-latest
|
|
56
58
|
strategy:
|
|
57
59
|
fail-fast: false
|
|
@@ -61,16 +63,17 @@ jobs:
|
|
|
61
63
|
steps:
|
|
62
64
|
- uses: actions/checkout@v6.0.2
|
|
63
65
|
|
|
64
|
-
- uses: dtolnay/rust-toolchain@
|
|
66
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
65
67
|
|
|
66
68
|
- uses: actions/setup-python@v6.2.0
|
|
67
69
|
with:
|
|
68
70
|
python-version: "3.13"
|
|
69
|
-
allow-prereleases: true
|
|
70
71
|
|
|
71
|
-
- run: pip install virtualenv
|
|
72
|
+
- run: pip install virtualenv
|
|
73
|
+
- run: pip install -r requirements-dev.txt
|
|
72
74
|
- run: virtualenv --no-vcs-ignore .venv
|
|
75
|
+
|
|
73
76
|
- run: maturin develop --features use-small-offset
|
|
74
|
-
- run: pytest -v
|
|
77
|
+
- run: pytest -v -n auto
|
|
75
78
|
env:
|
|
76
79
|
HYPOTHESIS_PROFILE: slow
|
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
# It is not intended for manual editing.
|
|
3
3
|
version = 4
|
|
4
4
|
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "allocator-api2"
|
|
7
|
+
version = "0.4.0"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "c880a97d28a3681c0267bd29cff89621202715b065127cd445fa0f0fe0aa2880"
|
|
10
|
+
|
|
5
11
|
[[package]]
|
|
6
12
|
name = "android_system_properties"
|
|
7
13
|
version = "0.1.5"
|
|
@@ -31,8 +37,9 @@ checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
|
|
|
31
37
|
|
|
32
38
|
[[package]]
|
|
33
39
|
name = "cachebox"
|
|
34
|
-
version = "6.2.
|
|
40
|
+
version = "6.2.1"
|
|
35
41
|
dependencies = [
|
|
42
|
+
"allocator-api2",
|
|
36
43
|
"cfg-if",
|
|
37
44
|
"chrono",
|
|
38
45
|
"fastrand",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "cachebox"
|
|
3
|
-
version = "6.2.
|
|
3
|
+
version = "6.2.1"
|
|
4
4
|
edition = "2021"
|
|
5
5
|
description = "The fastest memoizing and caching Python library written in Rust"
|
|
6
6
|
readme = "README.md"
|
|
@@ -22,12 +22,12 @@ panic = "abort"
|
|
|
22
22
|
strip = true
|
|
23
23
|
|
|
24
24
|
[dependencies]
|
|
25
|
+
allocator-api2 = "0.4.0"
|
|
25
26
|
cfg-if = "1.0.4"
|
|
26
27
|
chrono = "0.4.44"
|
|
27
28
|
fastrand = "2.4.1"
|
|
28
29
|
parking_lot = {version="0.12.5", default-features=false}
|
|
29
30
|
pyo3 = {version="0.29", default-features=false, features=["macros", "chrono"]}
|
|
30
|
-
# tokio = {version="1.52.3", default-features=false, features=["sync"]}
|
|
31
31
|
|
|
32
32
|
[build-dependencies]
|
|
33
33
|
pyo3-build-config = {version="0.29", default-features=false, features=["resolve-config"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
pub(crate) use self::inner::do_alloc;
|
|
2
|
+
#[cfg(test)]
|
|
3
|
+
pub(crate) use self::inner::AllocError;
|
|
4
|
+
pub(crate) use self::inner::Allocator;
|
|
5
|
+
pub(crate) use self::inner::Global;
|
|
6
|
+
|
|
7
|
+
mod inner {
|
|
8
|
+
#[cfg(test)]
|
|
9
|
+
pub(crate) use allocator_api2::alloc::AllocError;
|
|
10
|
+
pub(crate) use allocator_api2::alloc::Allocator;
|
|
11
|
+
pub(crate) use allocator_api2::alloc::Global;
|
|
12
|
+
use core::alloc::Layout;
|
|
13
|
+
use core::ptr::NonNull;
|
|
14
|
+
|
|
15
|
+
pub(crate) fn do_alloc<A: Allocator>(alloc: &A, layout: Layout) -> Result<NonNull<[u8]>, ()> {
|
|
16
|
+
match alloc.allocate(layout) {
|
|
17
|
+
Ok(ptr) => Ok(ptr),
|
|
18
|
+
Err(_) => Err(()),
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -4,7 +4,6 @@ use super::control::Tag;
|
|
|
4
4
|
use super::control::TagSliceExt;
|
|
5
5
|
use super::scopeguard::guard;
|
|
6
6
|
use super::scopeguard::ScopeGuard;
|
|
7
|
-
use super::util::invalid_mut;
|
|
8
7
|
use super::util::likely;
|
|
9
8
|
use super::util::unlikely;
|
|
10
9
|
use super::TryReserveError;
|
|
@@ -333,7 +332,7 @@ impl<T> Bucket<T> {
|
|
|
333
332
|
// won't overflow because index must be less than length (bucket_mask)
|
|
334
333
|
// and bucket_mask is guaranteed to be less than `isize::MAX`
|
|
335
334
|
// (see TableLayout::calculate_layout_for method)
|
|
336
|
-
|
|
335
|
+
ptr::without_provenance_mut(index + 1)
|
|
337
336
|
} else {
|
|
338
337
|
unsafe { base.as_ptr().sub(index) }
|
|
339
338
|
};
|
|
@@ -422,7 +421,7 @@ impl<T> Bucket<T> {
|
|
|
422
421
|
if T::IS_ZERO_SIZED {
|
|
423
422
|
// Just return an arbitrary ZST pointer which is properly aligned
|
|
424
423
|
// invalid pointer is good enough for ZST
|
|
425
|
-
|
|
424
|
+
ptr::without_provenance_mut(mem::align_of::<T>())
|
|
426
425
|
} else {
|
|
427
426
|
unsafe { self.ptr.as_ptr().sub(1) }
|
|
428
427
|
}
|
|
@@ -470,7 +469,7 @@ impl<T> Bucket<T> {
|
|
|
470
469
|
unsafe fn next_n(&self, offset: usize) -> Self {
|
|
471
470
|
let ptr = if T::IS_ZERO_SIZED {
|
|
472
471
|
// invalid pointer is good enough for ZST
|
|
473
|
-
|
|
472
|
+
ptr::without_provenance_mut(self.ptr.as_ptr() as usize + offset)
|
|
474
473
|
} else {
|
|
475
474
|
unsafe { self.ptr.as_ptr().sub(offset) }
|
|
476
475
|
};
|
|
@@ -3479,7 +3478,7 @@ impl<T, A: Allocator + Default> Default for RawTable<T, A> {
|
|
|
3479
3478
|
}
|
|
3480
3479
|
}
|
|
3481
3480
|
|
|
3482
|
-
|
|
3481
|
+
impl<T, A: Allocator> Drop for RawTable<T, A> {
|
|
3483
3482
|
#[cfg_attr(feature = "inline-more", inline)]
|
|
3484
3483
|
fn drop(&mut self) {
|
|
3485
3484
|
// SAFETY:
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#[inline(always)]
|
|
2
|
+
#[cold]
|
|
3
|
+
fn cold_path() {}
|
|
4
|
+
|
|
5
|
+
#[inline(always)]
|
|
6
|
+
pub(crate) fn likely(b: bool) -> bool {
|
|
7
|
+
if b {
|
|
8
|
+
true
|
|
9
|
+
} else {
|
|
10
|
+
cold_path();
|
|
11
|
+
false
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
#[inline(always)]
|
|
16
|
+
pub(crate) fn unlikely(b: bool) -> bool {
|
|
17
|
+
if b {
|
|
18
|
+
cold_path();
|
|
19
|
+
true
|
|
20
|
+
} else {
|
|
21
|
+
false
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -103,7 +103,7 @@ impl<T> OnceInit<T> {
|
|
|
103
103
|
/// Panics if called before [`set`](Self::set) has completed.
|
|
104
104
|
#[inline]
|
|
105
105
|
pub fn get(&self) -> &T {
|
|
106
|
-
if
|
|
106
|
+
if crate::hashbrown::util::likely(self.0.state.load(atomic::Ordering::Acquire) == INIT) {
|
|
107
107
|
// SAFETY: state == INIT guarantees `value` was fully written and is valid.
|
|
108
108
|
unsafe { (*self.0.value.get()).assume_init_ref() }
|
|
109
109
|
} else {
|
|
@@ -15,7 +15,7 @@ pub unsafe fn pyobject_hash(
|
|
|
15
15
|
arg1: *mut pyo3::ffi::PyObject,
|
|
16
16
|
) -> pyo3::PyResult<u64> {
|
|
17
17
|
let py_hash = pyo3::ffi::PyObject_Hash(arg1);
|
|
18
|
-
if
|
|
18
|
+
if crate::hashbrown::util::unlikely(py_hash == -1) {
|
|
19
19
|
// SAFETY: PyObject_Hash never returns -1 on success.
|
|
20
20
|
return Err(pyo3::PyErr::take(py).unwrap());
|
|
21
21
|
}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
#![feature(allocator_api)]
|
|
2
|
-
#![feature(dropck_eyepatch)]
|
|
3
|
-
#![feature(likely_unlikely)]
|
|
4
|
-
|
|
5
1
|
#[macro_use]
|
|
6
2
|
mod macro_rules;
|
|
7
3
|
mod hashbrown;
|
|
@@ -71,22 +67,22 @@ mod _core {
|
|
|
71
67
|
#[pymodule_export]
|
|
72
68
|
use crate::pyclasses::ttlcache::PyTTLCacheItems;
|
|
73
69
|
#[pymodule_export]
|
|
70
|
+
use crate::pyclasses::ttlcache::PyTTLCacheItemsWithExpire;
|
|
71
|
+
#[pymodule_export]
|
|
74
72
|
use crate::pyclasses::ttlcache::PyTTLCacheKeys;
|
|
75
73
|
#[pymodule_export]
|
|
76
74
|
use crate::pyclasses::ttlcache::PyTTLCacheValues;
|
|
77
|
-
#[pymodule_export]
|
|
78
|
-
use crate::pyclasses::ttlcache::PyTTLCacheItemsWithExpire;
|
|
79
75
|
|
|
80
76
|
#[pymodule_export]
|
|
81
77
|
use crate::pyclasses::vttlcache::PyVTTLCache;
|
|
82
78
|
#[pymodule_export]
|
|
83
79
|
use crate::pyclasses::vttlcache::PyVTTLCacheItems;
|
|
84
80
|
#[pymodule_export]
|
|
81
|
+
use crate::pyclasses::vttlcache::PyVTTLCacheItemsWithExpire;
|
|
82
|
+
#[pymodule_export]
|
|
85
83
|
use crate::pyclasses::vttlcache::PyVTTLCacheKeys;
|
|
86
84
|
#[pymodule_export]
|
|
87
85
|
use crate::pyclasses::vttlcache::PyVTTLCacheValues;
|
|
88
|
-
#[pymodule_export]
|
|
89
|
-
use crate::pyclasses::vttlcache::PyVTTLCacheItemsWithExpire;
|
|
90
86
|
|
|
91
87
|
#[pymodule_init]
|
|
92
88
|
pub fn init(m: &pyo3::Bound<'_, pyo3::types::PyModule>) -> pyo3::PyResult<()> {
|
|
@@ -299,7 +299,8 @@ impl PolicyExt for FIFOPolicy {
|
|
|
299
299
|
let front = unsafe { front.unwrap_unchecked() };
|
|
300
300
|
|
|
301
301
|
let eq = |index: &usize| Ok::<_, pyo3::PyErr>(*index - self.front_offset == 0);
|
|
302
|
-
|
|
302
|
+
let removed_key_table = self.table.remove_entry(front.key().hash(), eq).unwrap();
|
|
303
|
+
if crate::hashbrown::util::unlikely(removed_key_table.is_none()) {
|
|
303
304
|
unreachable!("popitem key not found in table");
|
|
304
305
|
}
|
|
305
306
|
|
|
@@ -322,12 +322,8 @@ impl TTLPolicy {
|
|
|
322
322
|
}
|
|
323
323
|
|
|
324
324
|
let eq = |index: &usize| Ok::<_, pyo3::PyErr>((*index - self.front_offset) == 0);
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
.remove_entry(handle.key().hash(), eq)
|
|
328
|
-
.unwrap()
|
|
329
|
-
.is_none(),
|
|
330
|
-
) {
|
|
325
|
+
let removed_key_table = self.table.remove_entry(handle.key().hash(), eq).unwrap();
|
|
326
|
+
if crate::hashbrown::util::unlikely(removed_key_table.is_none()) {
|
|
331
327
|
unreachable!("popitem key not found in table");
|
|
332
328
|
}
|
|
333
329
|
|
|
@@ -430,7 +426,8 @@ impl PolicyExt for TTLPolicy {
|
|
|
430
426
|
let front = unsafe { front.unwrap_unchecked() };
|
|
431
427
|
|
|
432
428
|
let eq = |index: &usize| Ok::<_, pyo3::PyErr>(*index - self.front_offset == 0);
|
|
433
|
-
|
|
429
|
+
let removed_key_table = self.table.remove_entry(front.key().hash(), eq).unwrap();
|
|
430
|
+
if crate::hashbrown::util::unlikely(removed_key_table.is_none()) {
|
|
434
431
|
unreachable!("popitem key not found in table");
|
|
435
432
|
}
|
|
436
433
|
|
|
@@ -632,7 +632,7 @@ async def test_async_recursive_cached_issue_54(
|
|
|
632
632
|
def test_recursive_cached(random_cache_impl: type[cachebox.BaseCacheImpl]):
|
|
633
633
|
obj = random_cache_impl(10)
|
|
634
634
|
|
|
635
|
-
@cachebox.cached(obj)
|
|
635
|
+
@cachebox.cached(obj, lock=False)
|
|
636
636
|
def factorial(n):
|
|
637
637
|
if n < 0:
|
|
638
638
|
raise ValueError
|
|
@@ -654,7 +654,7 @@ def test_recursive_threading_cached():
|
|
|
654
654
|
|
|
655
655
|
obj = cachebox.LRUCache(10)
|
|
656
656
|
|
|
657
|
-
@cachebox.cached(obj)
|
|
657
|
+
@cachebox.cached(obj, lock=False)
|
|
658
658
|
def factorial(n):
|
|
659
659
|
if n < 0:
|
|
660
660
|
raise ValueError
|
|
@@ -680,7 +680,7 @@ def test_recursive_threading_cached():
|
|
|
680
680
|
async def test_recursive_asyncio_cached():
|
|
681
681
|
obj = cachebox.LRUCache(10)
|
|
682
682
|
|
|
683
|
-
@cachebox.cached(obj)
|
|
683
|
+
@cachebox.cached(obj, lock=False)
|
|
684
684
|
async def factorial(n) -> int:
|
|
685
685
|
if n < 0:
|
|
686
686
|
raise ValueError
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
use core::ptr::NonNull;
|
|
2
|
-
|
|
3
|
-
#[cfg(test)]
|
|
4
|
-
pub(crate) use std::alloc::AllocError;
|
|
5
|
-
use std::alloc::Layout;
|
|
6
|
-
pub(crate) use std::alloc::{Allocator, Global};
|
|
7
|
-
|
|
8
|
-
pub(crate) fn do_alloc<A: Allocator>(alloc: &A, layout: Layout) -> Result<NonNull<[u8]>, ()> {
|
|
9
|
-
match alloc.allocate(layout) {
|
|
10
|
-
Ok(ptr) => Ok(ptr),
|
|
11
|
-
Err(_) => Err(()),
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
pub(crate) use std::hint::likely;
|
|
2
|
-
pub(crate) use std::hint::unlikely;
|
|
3
|
-
|
|
4
|
-
// FIXME: use strict provenance functions once they are stable.
|
|
5
|
-
// Implement it with a transmute for now.
|
|
6
|
-
#[inline(always)]
|
|
7
|
-
pub(crate) fn invalid_mut<T>(addr: usize) -> *mut T {
|
|
8
|
-
unsafe { core::mem::transmute(addr) }
|
|
9
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|