Skip to content

Commit

Permalink
Fix TTLCache and RRCache __str__ bug
Browse files Browse the repository at this point in the history
  • Loading branch information
awolverp committed Oct 16, 2024
1 parent fe611de commit 20190c5
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 43 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
python-version: ">=3.8 <=3.13"
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
python-version: ">=3.8 <=3.13"
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
Expand All @@ -91,7 +91,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
python-version: ">=3.8 <=3.13"
architecture: ${{ matrix.platform.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
Expand All @@ -110,15 +110,15 @@ jobs:
strategy:
matrix:
platform:
- runner: macos-12
- runner: macos-14
target: x86_64
- runner: macos-14
target: aarch64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
python-version: ">=3.8 <=3.13"
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
- name: set up python
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.13'

- run: pip install pytest maturin

Expand Down
41 changes: 18 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ strip = "symbols"
[dependencies]
hashbrown = { version = "^0.14", default-features = false, features=["inline-more", "raw"]}
fastrand = "^2.1"
pyo3 = { git = "https://github.com/PyO3/pyo3.git", default-features = false, features=["macros", "extension-module"] }
pyo3 = { version = "^0.22", default-features = false, features=["macros", "extension-module"] }
cfg-if = "1.0"
parking_lot_core = { version = "^0.9", default-features = false }
lock_api = { version = "^0.4", default-features = false }
fxhash = {version="^0.2"}

[build-dependencies]
pyo3-build-config = { version = "=0.22.4", features = ["resolve-config"] }
pyo3-build-config = { version = "^0.22", features = ["resolve-config"] }

[lints.clippy]
dbg_macro = "warn"
Expand Down
4 changes: 2 additions & 2 deletions src/bridge/rrcache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl RRCache {
let lock = self.raw.lock();

format!(
"Cache({} / {}, capacity={})",
"RRCache({} / {}, capacity={})",
lock.table.len(),
lock.maxsize.get(),
lock.table.capacity(),
Expand Down Expand Up @@ -409,7 +409,7 @@ impl RRCache {

Ok(())
} else {
for pair in iterable.bind(py).try_iter()? {
for pair in iterable.bind(py).iter()? {
let (key, value) = pair?.extract::<(pyo3::PyObject, pyo3::PyObject)>()?;

let hk = HashedKey::from_pyobject(py, key)?;
Expand Down
3 changes: 2 additions & 1 deletion src/bridge/ttlcache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ impl TTLCache {
lock.expire();

format!(
"FIFOCache({} / {}, capacity={})",
"TTLCache({} / {}, ttl={}, capacity={})",
lock.table.len(),
lock.maxsize.get(),
lock.ttl.as_secs_f64(),
lock.table.capacity(),
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/internal/fifo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl FIFOPolicy {

Ok(())
} else {
for pair in iterable.bind(py).try_iter()? {
for pair in iterable.bind(py).iter()? {
let (key, value) = pair?.extract::<(pyo3::PyObject, pyo3::PyObject)>()?;

let hk = HashedKey::from_pyobject(py, key)?;
Expand Down
4 changes: 2 additions & 2 deletions src/internal/lfu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl LFUPolicy {

Ok(())
} else {
for pair in iterable.bind(py).try_iter()? {
for pair in iterable.bind(py).iter()? {
let (key, value) = pair?.extract::<(pyo3::PyObject, pyo3::PyObject)>()?;

let hk = HashedKey::from_pyobject(py, key)?;
Expand Down Expand Up @@ -267,7 +267,7 @@ impl LFUPolicy {

let mut new = Self::new(maxsize, capacity)?;

for pair in iterable.bind(py).try_iter()? {
for pair in iterable.bind(py).iter()? {
let (key, value, fr) = pair?.extract::<(pyo3::PyObject, pyo3::PyObject, usize)>()?;

let hk = HashedKey::from_pyobject(py, key)?;
Expand Down
2 changes: 1 addition & 1 deletion src/internal/lru.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl LRUPolicy {

Ok(())
} else {
for pair in iterable.bind(py).try_iter()? {
for pair in iterable.bind(py).iter()? {
let (key, value) = pair?.extract::<(pyo3::PyObject, pyo3::PyObject)>()?;

let hk = HashedKey::from_pyobject(py, key)?;
Expand Down
2 changes: 1 addition & 1 deletion src/internal/nopolicy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl NoPolicy {

Ok(())
} else {
for pair in iterable.bind(py).try_iter()? {
for pair in iterable.bind(py).iter()? {
let (key, value) = pair?.extract::<(pyo3::PyObject, pyo3::PyObject)>()?;

let hk = HashedKey::from_pyobject(py, key)?;
Expand Down
4 changes: 2 additions & 2 deletions src/internal/ttl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl TTLPolicy {

Ok(())
} else {
for pair in iterable.bind(py).try_iter()? {
for pair in iterable.bind(py).iter()? {
let (key, value) = pair?.extract::<(pyo3::PyObject, pyo3::PyObject)>()?;

let hk = HashedKey::from_pyobject(py, key)?;
Expand Down Expand Up @@ -344,7 +344,7 @@ impl TTLPolicy {

let mut new = Self::new(maxsize, capacity, ttl)?;

for pair in iterable.bind(py).try_iter()? {
for pair in iterable.bind(py).iter()? {
let (key, value, timestamp) =
pair?.extract::<(pyo3::PyObject, pyo3::PyObject, f64)>()?;

Expand Down
4 changes: 2 additions & 2 deletions src/internal/vttl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ impl VTTLPolicy {

Ok(())
} else {
for pair in iterable.bind(py).try_iter()? {
for pair in iterable.bind(py).iter()? {
let (key, value) = pair?.extract::<(pyo3::PyObject, pyo3::PyObject)>()?;

let hk = HashedKey::from_pyobject(py, key)?;
Expand Down Expand Up @@ -362,7 +362,7 @@ impl VTTLPolicy {

let mut new = Self::new(maxsize, capacity)?;

for pair in iterable.bind(py).try_iter()? {
for pair in iterable.bind(py).iter()? {
let (key, value, timestamp) =
pair?.extract::<(pyo3::PyObject, pyo3::PyObject, f64)>()?;

Expand Down

0 comments on commit 20190c5

Please sign in to comment.