Memcache service not working - how to handle?

I am using Memcache in my ASP.NET application. I have 3 memcache servers to which it connects. If all of them are omitted, there is a significant delay in page loading. When all servers are down, I do not want to use memcache.

When I stepped over the code, I noticed that when the servers are down, memcache code does not throw an exception (I thought I could "Catch" it in my application and take the necessary steps).

How can I handle this situation?

+3
source share
3 answers

Since Enyim is Open Source, you can edit ServerPool.cs , for example:

    /// <summary>
    /// Marks a node as dead (unusable)
    ///  - moves hte node to the  "dead list"
    ///  - recreates the locator based on the new list of still functioning servers
    /// </summary>
    /// <param name="node"></param>
    private void MarkAsDead(MemcachedNode node)
    {
        this.serverAccessLock.UpgradeToWriterLock(Timeout.Infinite);

        try
        {
            // server gained AoeREZ while AFK?
            if (!node.IsAlive)
            {
                this.workingServers.Remove(node);
                this.deadServers.Add(node);

                // check if all servers are dead
                if (this.workingServers.Count == 0)
                    throw new NoMoreServersException();

                this.RebuildIndexes();
            }
        }
        finally
        {
            this.serverAccessLock.ReleaseLock();
        }
    }

. , - :

    // check if all servers are dead
    if (this.workingServers.Count == 0)
        throw new NoMoreServersException();

NoMoreServersException ( ( )).

+1

, , .

, .

public class CacheManager
{
    protected ICacheProvider _repository;
    public CacheManager(ICacheProvider repository)
    {
        _repository = repository;
    }

    public void Store(string key, object data)
    {
        _repository.Store(key, data);
    }

    public void Destroy(string key)
    {
        _repository.Destroy(key);
    }

    public T Get<T>(string key)
    {
        return _repository.Get<T>(key);
    }
}

, , memcache ? , db/filessystem/etc. , .

, memcached * nix, . Memcached - . /, . - munin IMHO

+2

, ? :

  • , ( ). , .
  • , . , .

, , , memcached . monit .

0

Source: https://habr.com/ru/post/1722024/