MCPcopy Create free account
hub / github.com/FastFlowLM/FastFlowLM / can_use_cache

Method can_use_cache

src/include/prompt_cache.hpp:121–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119
120
121 bool can_use_cache(json& messages, chat_template_type_t template_type, json& tools) {
122 (void)template_type;
123 if (messages.size() <= 2) {
124 update_message_checksum(messages);
125 update_tool_checksum(tools);
126 return false;
127 }
128
129 const uint64_t check_sum_to_compare = _calculate_message_checksum(messages, messages.size() - 2);
130 const uint64_t new_checksum = _calculate_message_checksum(messages, messages.size());
131 std::vector<uint64_t> new_tool_checksums = _calculate_tool_checksums(tools);
132
133 const bool can_use_message = checksum_ == check_sum_to_compare;
134 const bool can_use_tools = tool_checksums_ == new_tool_checksums;
135
136 checksum_ = new_checksum;
137 tool_checksums_ = std::move(new_tool_checksums);
138
139 return can_use_message && can_use_tools;
140 }
141
142 /// @brief Reset the checksum to force cache miss
143 /// @note This function increments the checksum value by 1 to ensure that

Callers 1

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected