Source
int zbx_tfc_get_value(zbx_uint64_t itemid, time_t start, time_t end, zbx_trend_function_t function, double *value,
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
typedef struct
{
zbx_uint64_t itemid; /* the itemid */
int start; /* the period start time */
int end; /* the period end time */
zbx_trend_function_t function; /* the trends function */
zbx_trend_state_t state; /* the cached value state */
double value; /* the cached value */
zbx_uint32_t prev; /* index of the previous LRU list or unused entry */
zbx_uint32_t next; /* index of the next LRU list or unused entry */
zbx_uint32_t prev_value; /* index of the previous value list */
zbx_uint32_t next_value; /* index of the next value list */
}
zbx_tfc_data_t;
typedef struct
{
char header[ZBX_HASHSET_ENTRY_OFFSET];
zbx_tfc_data_t data;
}
zbx_tfc_slot_t;
typedef struct
{
zbx_hashset_t index;
zbx_tfc_slot_t *slots;
size_t slots_size;
zbx_uint32_t slots_num;
zbx_uint32_t free_slot;
zbx_uint32_t free_head;
zbx_uint32_t lru_head;
zbx_uint32_t lru_tail;
zbx_uint64_t hits;
zbx_uint64_t misses;
zbx_uint64_t items_num;
zbx_uint64_t conf_size;
}
zbx_tfc_t;
static zbx_tfc_t *cache = NULL;
static int alloc_num = 0;