---
name: "ACE_LRU_Caching_Strategy"
section: "3"
platform: "linux"
package: "libace-doc"
version: "5.0.7-4"
release: "Debian 2.2 (Potato)"
platforms: ["linux"]
url: "https://new.carta.tech/ACE_LRU_Caching_Strategy"
---

# ACE\_LRU\_Caching\_Strategy(3)

Defines a Least Recently Used strategy which will decide on the item to be removed from the cache.

## NAME

ACE\_LRU\_Caching\_Strategy -  Defines a Least Recently Used strategy which will decide on the item to be removed from the cache.

## SYNOPSIS

```
#include <ace/Caching_Strategies_T.h>
template<class ATTRIBUTES, class CACHING_UTILITY>
class ACE_LRU_Caching_Strategy
{
  public:
    typedef ATTRIBUTES CACHING_ATTRIBUTES;
    ACE_LRU_Caching_Strategy (void);
    ATTRIBUTES attributes (void);
    double purge_percent (void);
    void purge_percent (double percentage);
    int notify_bind (int result, const ATTRIBUTES &attr);
    int notify_find (int result, ATTRIBUTES &attr);
    int notify_unbind (int result, const ATTRIBUTES &attr);
    int notify_trybind (int result, ATTRIBUTES &attr);
    int notify_rebind (int result, const ATTRIBUTES &attr);
    CACHING_UTILITY &caching_utility (void);
    void dump (void) const;
  private:
    ATTRIBUTES timer_;
    double purge_percent_;
    CACHING_UTILITY caching_utility_;
};
```

## DESCRIPTION

This is a strategy which makes use of a virtual timer which is updated whenever an item is inserted or looked up in the container. When the need of purging entries arises, the items with the lowest timer values are removed.

Explanation of the template parameter list: CONTAINER is any map with entries of type KEY, VALUE. The ATTRIBUTES are the deciding factor for purging of entries and should logically be included with the VALUE. Some ways of doing this are: As being a member of the VALUE or VALUE being ACE\_Pairx, ATTRIBUTES. The CACHING\_UTILITY is the class which can be plugged in and which decides the entries to purge.

## Initialisation and termination.

```
ACE_LRU_Caching_Strategy (void);
```

The container is the map in which the entries reside.  The timer attribute is initialed to zero in this constructor.  And the purge\_percent field denotes the percentage of the entries in the cache which can be purged automagically and by default is set to 10%.

## Operations of the strategy.

```
ATTRIBUTES attributes (void);
```

Accessor method for the timer attributes.

## Accessor methods for the percentage of entries to purge.

```
double purge_percent (void);
```

```
void purge_percent (double percentage);
```

\=  Strategy related Operations

```
int notify_bind (int result, const ATTRIBUTES &attr);
```

This method acts as a notification about the CONTAINERs bind method call.

```
int notify_find (int result, ATTRIBUTES &attr);
```

This method acts as a notification about the CONTAINERs find method call

```
int notify_unbind (int result, const ATTRIBUTES &attr);
```

This method acts as a notification about the CONTAINERs unbind method call

```
int notify_trybind (int result, ATTRIBUTES &attr);
```

This method acts as a notification about the CONTAINERs trybind method call

```
int notify_rebind (int result, const ATTRIBUTES &attr);
```

This method acts as a notification about the CONTAINERs rebind method call

```
CACHING_UTILITY &caching_utility (void);
```

Purge the cache.

```
void dump (void) const;
```

Dumps the state of the object.

## AUTHOR

Kirthika Parameswaran kirthika@cs.wustl.edu

## LIBRARY

ace
