> ## Documentation Index
> Fetch the complete documentation index at: https://whatsapp-rust.jlucaso.com/llms.txt
> Use this file to discover all available pages before exploring further.

# June 9, 2026 — LidPnEntry: Arc<str> fields for unbounded-cache memory savings

> LidPnEntry.lid and .phone_number are now Arc<str>. Cache keys share the entry's Arc allocations, halving per-mapping heap objects in the unbounded LID-PN cache.

## Performance

**`LidPnEntry` fields changed from `String` to `Arc<str>` ([#811](https://github.com/oxidezap/whatsapp-rust/pull/811))**

`LidPnEntry.lid` and `.phone_number` are now `Arc<str>`. `LidPnCache::add` clones the entry's own `Arc`s as the map keys for both lookup directions, so each identifier lives once per mapping instead of once as a key and again inside the entry.

This cache is **unbounded by design** (no TTL, no capacity ceiling — matching `WAWebLidPnCache`), so per-entry byte savings compound over the full contact base: roughly **40–80 bytes per mapping**, or **\~0.5–1 MB retained** for a process that has learned 10k LID-PN mappings.

### Migration

**Constructors are source-compatible.** `LidPnEntry::new` and `LidPnEntry::with_timestamp` accept `impl Into<Arc<str>>`, so both `String` and `&str` arguments continue to compile without changes.

**Direct field reads return `Arc<str>` instead of `String`.** Code that accesses `.lid` or `.phone_number` directly needs a deref for `&str` comparisons:

```rust theme={null}
// Before
assert_eq!(entry.lid, some_string);

// After
assert_eq!(&*entry.lid, some_string);
// or
assert_eq!(entry.lid.as_ref(), some_string);
```

`Display` and format strings work unchanged — `Arc<str>` implements `Display`.

**`get_phone_number` return type unchanged.** It still returns `String` (cost-identical to before).

**Wire/persistence unchanged.** `Arc<str>` serializes as a plain JSON string, so persisted `lid_pn_mapping` rows and custom `CacheStore` backends are unaffected.

### Summary

|                                         | Before      | After                                          |
| --------------------------------------- | ----------- | ---------------------------------------------- |
| `LidPnEntry.lid` / `.phone_number` type | `String`    | `Arc<str>`                                     |
| Constructor argument types              | `String`    | `impl Into<Arc<str>>` (String/\&str both work) |
| `get_phone_number` return type          | `String`    | `String` (unchanged)                           |
| Heap allocations per mapping in cache   | \~4 strings | \~2 strings (shared)                           |
| Wire/persistence format                 | JSON string | JSON string (unchanged)                        |
