---
# System prepended metadata

title: '2025-07-23'

---

# 2025-07-23

## Persistent caching

* Macroless
* Can't really derive serialize/deserialize
* Can only do so on the fields
* Can we have a less macro-heavy approach
* But not highly prioritized
* Discussion: https://salsa.zulipchat.com/#narrow/channel/333573-Contributing-to-Salsa/topic/Less.20macros/near/528092220

Code:

```rust
#[derive(salsa::Interned)]
struct MyInterned { foo: Foo }

let interned: salsa::Interned<'db, MyInterned> salsa::Interned::new(&db, MyInterned {
    foo: Foo::new()
});
let value: &MyInterned = interned.read(&db); // Interned structs can be loaded directly.

#[derive(salsa::Tracked)]
struct MyTracked {
    bar: Bar,
    #[salsa(tracked)]
    baz: Baz
}

// == generated by derive ==
// struct MyTrackedRef<'db> { // Only gives direct access to untracked fields.
//     bar: &'db Bar,
//     baz: TrackedField<Baz> // A salsa type that holds the struct ID and field index.
// }
//
// impl salsa::TrackedRef for MyTrackedRef {
//    type Ref<'db> = MyTrackedRef<'db>;
// }

let tracked: salsa::Tracked<'db, Foo> = salsa::Tracked::new(&db, MyTracked {
    bar: Bar::new(),
    baz: Baz::new()
});

let data: MyTracked::Ref<'db> = tracked.read(&db);
let bar: &'db Bar = data.bar; // Access untracked fields directly.
let baz: &'db Baz = data.baz.read(&db); // Tracked fields have to be loaded.
let full_data: &'db MyTracked = tracked.read_full(&db); // The entire struct can be loaded as well, adding a dependency on all tracked fields.

```

## Inventory

Niko is in favor

## Persitent caching

Continuing to build a prototype

Questions are coming up


