---
title: RateCounter
summary: A rate counter that can be used with an edge rate limiter or stand alone for counting and rate calculations
url: https://www.fastly.com/documentation/reference/compute/sdks/cpp/fastly/erl/class.RateCounter/
---

**Kind:** Class  
**Module:** [erl](https://www.fastly.com/documentation/reference/compute/sdks/cpp/fastly/erl/)  
**Package:** compute-sdk-cpp 0.7.0  
**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/erl.h#L60

Include `fastly/erl.h` to use this class.

A rate counter that can be used with an edge rate limiter or stand alone for counting and rate calculations

## Constructor

**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/erl.h#L62

```cpp
explicit fastly::erl::RateCounter::RateCounter(std::string name)
```

**Parameters**

- `name`: `std::string`

## Methods

### increment

**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/erl.h#L64

```cpp
tl::expected<void, ERLError> fastly::erl::RateCounter::increment(std::string_view entry, std::uint32_t delta)
```

Increment an entry in the ratecounter by delta.

**Parameters**

- `entry`: `std::string_view`
- `delta`: `std::uint32_t`

**Returns**

`tl::expected<void, ERLError>`

### lookup_count

**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/erl.h#L71

```cpp
tl::expected<std::uint32_t, ERLError> fastly::erl::RateCounter::lookup_count(std::string_view entry, CounterDuration duration) const
```

Lookup the current count for entry in the rate counter for a duration.

**Parameters**

- `entry`: `std::string_view`
- `duration`: `CounterDuration`

**Returns**

`tl::expected<std::uint32_t, ERLError>`

### lookup_rate

**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/erl.h#L67

```cpp
tl::expected<std::uint32_t, ERLError> fastly::erl::RateCounter::lookup_rate(std::string_view entry, RateWindow window) const
```

Lookup the current rate for entry in the rate counter for a window.

**Parameters**

- `entry`: `std::string_view`
- `window`: `RateWindow`

**Returns**

`tl::expected<std::uint32_t, ERLError>`

### name

**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/erl.h#L72

```cpp
std::string_view fastly::erl::RateCounter::name() const
```

**Returns**

`std::string_view`
