---
title: llarp::layers::flow::NameCache
summary: cache for in network names (ONS records) with static TTL. 

---

# llarp::layers::flow::NameCache



cache for in network names (ONS records) with static TTL.  [More...](#detailed-description)


`#include <name_cache.hpp>`

## Public Functions

|                | Name           |
| -------------- | -------------- |
| | **[NameCache](Classes/classllarp_1_1layers_1_1flow_1_1NameCache.md#function-namecache)**(std::chrono::seconds ttl =5min) |
| std::optional< [FlowAddr](Classes/classllarp_1_1layers_1_1flow_1_1FlowAddr.md) > | **[get](Classes/classllarp_1_1layers_1_1flow_1_1NameCache.md#function-get)**(std::string name)<br>apply any cache expiry then get an entry from the cache if it exists.  |
| void | **[put](Classes/classllarp_1_1layers_1_1flow_1_1NameCache.md#function-put)**(std::string name, [FlowAddr](Classes/classllarp_1_1layers_1_1flow_1_1FlowAddr.md) addr)<br>apply any cache expiry and then put a name into the cache.  |

## Detailed Description

```cpp
class llarp::layers::flow::NameCache;
```

cache for in network names (ONS records) with static TTL. 

has no negative lookup cache. 

## Public Functions Documentation

### function NameCache

```cpp
NameCache(
    std::chrono::seconds ttl =5min
)
```


### function get

```cpp
std::optional< FlowAddr > get(
    std::string name
)
```

apply any cache expiry then get an entry from the cache if it exists. 

### function put

```cpp
void put(
    std::string name,
    FlowAddr addr
)
```

apply any cache expiry and then put a name into the cache. 

-------------------------------

Updated on 2023-04-27 at 04:17:17 +0000