Function operator[]

Synopsis

#include <lib/inc/drogon/CacheMap.h>

T2 & operator[](const T1 &key)

Description

Return the reference to the value of the keyword.

Source

Lines 225-239 in lib/inc/drogon/CacheMap.h.

T2 &operator[](const T1 &key)
{
    int timeout = 0;
    std::lock_guard<std::mutex> lock(mtx_);
    auto iter = map_.find(key);
    if (iter != map_.end())
    {
        timeout = iter->second.timeout;
        if (timeout > 0)
            eraseAfter(timeout, key);
        return iter->second.value;
    }
    return map_[key].value;
}





Add Discussion as Guest

Log in to DocsForge