jaemk / cached

Rust cache structures and easy function memoization

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`compile_error!` when attempting to use `redis_store` feature

jqnatividad opened this issue · comments

First off, thanks @jaemk and @omid for adding Redis support!

So I just changed my cargo.toml cached entry from:

cached = "0.30"

to

cached = { version = "0.32", features = ["redis_store"] }

However, I'm getting the following error when I run cargo build:

tokio-comp or async-std-comp features required for aio feature
   --> /home/jqnatividad/.cargo/registry/src/github.com-1ecc6299db9ec823/redis-0.21.5/src/aio.rs:109:13
    |
109 |             compile_error!("tokio-comp or async-std-comp features required for aio feature")
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: tokio-comp or async-std-comp features required for aio feature
   --> /home/jqnatividad/.cargo/registry/src/github.com-1ecc6299db9ec823/redis-0.21.5/src/aio.rs:870:9
    |
870 |         compile_error!("tokio-comp or async-std-comp features required for aio feature");
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0433]: failed to resolve: use of undeclared type `ValueCodec`
   --> /home/jqnatividad/.cargo/registry/src/github.com-1ecc6299db9ec823/redis-0.21.5/src/aio.rs:179:9
    |
179 |         ValueCodec::default()
    |         ^^^^^^^^^^ not found in this scope
    |
help: consider importing this struct
    |
2   | use crate::parser::ValueCodec;
    |

error[E0433]: failed to resolve: use of undeclared type `ValueCodec`
   --> /home/jqnatividad/.cargo/registry/src/github.com-1ecc6299db9ec823/redis-0.21.5/src/aio.rs:191:9
    |
191 |         ValueCodec::default()
    |         ^^^^^^^^^^ not found in this scope
    |
help: consider importing this struct
    |
2   | use crate::parser::ValueCodec;
    |

error[E0433]: failed to resolve: use of undeclared type `ValueCodec`
   --> /home/jqnatividad/.cargo/registry/src/github.com-1ecc6299db9ec823/redis-0.21.5/src/aio.rs:220:9
    |
220 |         ValueCodec::default()
    |         ^^^^^^^^^^ not found in this scope
    |
help: consider importing this struct
    |
2   | use crate::parser::ValueCodec;
    |

error[E0433]: failed to resolve: use of undeclared type `ValueCodec`
   --> /home/jqnatividad/.cargo/registry/src/github.com-1ecc6299db9ec823/redis-0.21.5/src/aio.rs:229:9
    |
229 |         ValueCodec::default()
    |         ^^^^^^^^^^ not found in this scope
    |
help: consider importing this struct
    |
2   | use crate::parser::ValueCodec;
    |

error[E0433]: failed to resolve: use of undeclared type `ValueCodec`
   --> /home/jqnatividad/.cargo/registry/src/github.com-1ecc6299db9ec823/redis-0.21.5/src/aio.rs:872:21
    |
872 |         let codec = ValueCodec::default()
    |                     ^^^^^^^^^^ not found in this scope
    |
help: consider importing this struct
    |
2   | use crate::parser::ValueCodec;
    |

looking at the redis dependency:

cached/Cargo.toml

Lines 70 to 73 in 68f6619

[dependencies.redis]
version = "0.21"
features = ["r2d2", "aio"]
optional = true

It pulls in aio which triggers the compile_error!

woops, forgot to move that redis feature to be only included with the async features. I'll fix it this morning

released the fix in 0.32.1

also added a non-async redis example

CACHED_REDIS_CONNECTION_STRING=redis://127.0.0.1:6379 cargo run --example redis --features "redis_store"

to test it works when async features aren't enabled

Thanks for the quick turnaround! Caching with Redis is working like a dream!

The example allowed me to quickly adapt my project to use it.
https://github.com/jqnatividad/qsv/blob/master/src/cmd/fetch.rs#L15