---
title: llarp::util::DecayingHashTable

---

# llarp::util::DecayingHashTable



 [More...](#detailed-description)

## Public Functions

|                | Name           |
| -------------- | -------------- |
| | **[DecayingHashTable](Classes/structllarp_1_1util_1_1DecayingHashTable.md#function-decayinghashtable)**(std::chrono::milliseconds cacheInterval =1h) |
| void | **[Decay](Classes/structllarp_1_1util_1_1DecayingHashTable.md#function-decay)**(llarp_time_t now) |
| bool | **[Has](Classes/structllarp_1_1util_1_1DecayingHashTable.md#function-has)**(const Key_t & k) const<br>return if we have this value by key  |
| bool | **[Put](Classes/structllarp_1_1util_1_1DecayingHashTable.md#function-put)**(Key_t key, Value_t value, llarp_time_t now =0s)<br>return true if inserted return false if not inserted  |
| std::optional< Value_t > | **[Get](Classes/structllarp_1_1util_1_1DecayingHashTable.md#function-get)**(Key_t k) const<br>get value by key  |
| void | **[Remove](Classes/structllarp_1_1util_1_1DecayingHashTable.md#function-remove)**(const Key_t & key)<br>explicit remove an item from the cache by key  |

## Detailed Description

```cpp
template <typename Key_t ,
typename Value_t ,
typename Hash_t  =std::hash<Key_t>>
struct llarp::util::DecayingHashTable;
```

## Public Functions Documentation

### function DecayingHashTable

```cpp
inline DecayingHashTable(
    std::chrono::milliseconds cacheInterval =1h
)
```


### function Decay

```cpp
inline void Decay(
    llarp_time_t now
)
```


### function Has

```cpp
inline bool Has(
    const Key_t & k
) const
```

return if we have this value by key 

### function Put

```cpp
inline bool Put(
    Key_t key,
    Value_t value,
    llarp_time_t now =0s
)
```

return true if inserted return false if not inserted 

### function Get

```cpp
inline std::optional< Value_t > Get(
    Key_t k
) const
```

get value by key 

### function Remove

```cpp
inline void Remove(
    const Key_t & key
)
```

explicit remove an item from the cache by key 

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

Updated on 2022-10-26 at 17:18:04 +0000