| 65 | } |
| 66 | |
| 67 | void ZVecCachedSQLParser::put_into_cache(const std::string &query_cache_key, |
| 68 | const SQLInfo::Ptr &new_sql_info) { |
| 69 | { |
| 70 | std::unique_lock guard(shared_mutex_); |
| 71 | if (sql_info_map_.size() >= cache_count_) { |
| 72 | // if full, clear to refresh new sql |
| 73 | sql_info_map_.clear(); |
| 74 | Hit = Miss = 0; |
| 75 | } |
| 76 | sql_info_map_.emplace(query_cache_key, new_sql_info); |
| 77 | } |
| 78 | |
| 79 | LOG_DEBUG("cache emplaced. [%s] [%s] ", query_cache_key.c_str(), |
| 80 | new_sql_info->to_string().c_str()); |
| 81 | |
| 82 | return; |
| 83 | } |
| 84 | |
| 85 | SQLInfo::Ptr ZVecCachedSQLParser::get_from_cache(const std::string &query, |
| 86 | std::string *query_cache_key) { |