fission-codes / go-car-mirror

Generic Go implementation of the CAR Mirror protocol
Apache License 2.0
4 stars 0 forks source link

Session cache TTL #79

Open justindotpub opened 1 year ago

justindotpub commented 1 year ago

Currently sessions stay in cache until they are explicitly closed. After they are closed, session cache is cleared.

(We still have some stats in the global stats struct but not the session cache used for car mirror transport.)

We need to change the code to a TTL driven approach, per the spec. Session caches reside in memory until TTL expiration, and therefore subsequent requests in that time period utilize the cache.

Make sure that our code is resilient to session cache being purged at any point, even mid flight. Smaller devices may need to purge session cache at any point in order to free up limited available memory.

It feels to me like we need to ensure that the event loop currently used is an internal artifact only, not exposed to end users other than for debug purposes.

Make sure the provider cache is indexed by the peerId of the provider and root cid, per spec. PeerId of the provider as key in requester cache... what does this mean in the world of http and not necessarily libp2p? I assume it will be URL. I assume we don't use PeerID in a verifiable way... just looking for unique key for cache?

ETA: 2023-10-31