# Overriding Existing Methods

As you can see in standard implementation, all methods are marked as virtual which means you can customize their content via overriding them.

You can override the existing methods to create a new class. To do that, newly created classes should inherit from _**RENRedisCacheService**_ class:

```csharp
public class MyCacheService : RENRedisCacheService
{
    public MyCacheService(IConnectionMultiplexer connection, IConfiguration configuration) : base(connection, configuration) { }

    public override T Get<T>(string cacheKey, CancellationToken cancellationToken = default);)
    {
        Console.WriteLine("Getting...");
        //custom implementations
        return base.Get<T>(cacheKey, cancellationToken);
    }
}
```

{% hint style="warning" %}
**PLEASE BE CAREFUL** about the constructors. In _**In Memory**_ implementation _**RENInMemoryCacheService**_ needed _**IConfiguration**_ and _**IMemoryCache**_ injeciton. Here, _**RENRedisCacheService**_ needs _**IConfiguration**_ injection!
{% endhint %}

Here, we overrided the existing method to expand it's functionality. From now on, we have register _**MyCacheService**_ in _**Program.cs**_ instead of standard registeration:

```csharp
// builder.Services.RegisterRENCacheAccessHelpers<RENInMemoryCacheService>(); // SINCE WE ARE NOT USING STANDARD APPROACH ANYMORE
builder.Services.RegisterRENCacheAccessHelpers<MyCacheService>();
```

{% hint style="info" %}
Since we are registering classes that inherits from _**IRENCacheService**_, we can use _**MyCacheService**_ because we inherited from _**RENRedisCacheService**_ which inherits from _**ICacheService**_ interface!
{% endhint %}

And we may inject it to our classes as follows:

```csharp
public class HomeController : ControllerBase
{
    private readonly IRENCacheService _customCacheService;
    private readonly IRENRepository<User> _customCacheService;

    public HomeController(IRENUnitOfWork<RENDbContext> uow, IRENCacheService cacheService)
    {
        _userRepository = uow.GetRENRepository<User>();
        _cacheService = cacheService;
    }

    [HttpGet]
    [Route("Index")]
    public async Task<IActionResult> Index()
    {
        var cacheKey = "users";
        var users = await _cacheService.GetAsync<List<User>>(cacheKey);

        if (users != null) return Ok(users);
        users = await _userRepository.GetListAsync();
        await _cacheService.SetAsync(cacheKey, users);

        return Ok(users);
    }
}
```
