maxcountryman / tower-sessions-stores

🚃 Previously bundled session stores for `tower-sessions`.
https://github.com/maxcountryman/tower-sessions
MIT License
22 stars 7 forks source link

Cannot use RedisStore with CachingSessionStore #15

Closed Fyko closed 3 months ago

Fyko commented 3 months ago

When attempting to use a redis store within a caching session store, the following error is thrown:

the trait bound `RedisStore<RedisPool>: SessionStore` is not satisfied
the following other types implement trait `SessionStore`:
  MokaStore
  MemoryStore
  CachingSessionStore<Cache, Store>
session_store.rs(176, 60): required by a bound in `CachingSessionStore`

the trait bound `RedisStore<RedisPool>: SessionStore` is not satisfied
the following other types implement trait `SessionStore`:
  MokaStore
  MemoryStore
  CachingSessionStore<Cache, Store>rustc
lib.rs(61, 25): required by a bound introduced by this call
session_store.rs(181, 34): required by a bound in `CachingSessionStore::<Cache, Store>::new`

Sample code:

let config = RedisConfig::from_url(&CONFIG.redis_url).expect("failed to parse redis url");
let pool = RedisPool::new(config, None, None, None, 6).expect("failed to create redis pool");

let redis_conn = pool.connect();
tokio::spawn(async move {
    redis_conn.await.expect("redis died");
});
pool.wait_for_connect().await?;

let moka_store = MokaStore::new(Some(1440));
let redis_store = RedisStore::new(pool);
let caching_store = CachingSessionStore::new(moka_store, redis_store);
maxcountryman commented 3 months ago

Which versions of both stores are you using?

Currently MokaStore has been updated to the most recent release of tower-sessions but RedisStore has not.

Fyko commented 3 months ago

RedisStore on 0.11. I guess that would be the case. I looked at the commit history and there didn't look like there'd be an issue.

Thanks!

maxcountryman commented 3 months ago

We can update RedisStore but it would be more ideal to have transactions for pools first so we can properly implement the create method.