"Fossies" - the Fresh Open Source Software Archive

Member "memcached-1.6.15/stats_prefix.h" (21 Feb 2022, 1851 Bytes) of package /linux/www/memcached-1.6.15.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "stats_prefix.h" see the Fossies "Dox" file reference documentation.

    1 #ifndef STATS_PREFIX_H
    2 #define STATS_PREFIX_H
    3 
    4 /* The stats prefix subsystem stores detailed statistics for each key prefix.
    5  * Simple statistics like total number of GETS are stored by the Stats
    6  * subsystem defined elsewhere.
    7  *
    8  * Suppose the prefix delimiter is ":", then "user:123" and "user:456" both
    9  * have the same prefix "user".
   10  */
   11 
   12 
   13 /* Initialize the stats prefix subsystem. Should be called once before other
   14  * functions are called. The global hash initialization should be done before
   15  * using this subsystem.
   16  */
   17 void stats_prefix_init(char prefix_delimiter);
   18 
   19 /* Clear previously collected stats. Requires you to have the acquired
   20  * the STATS_LOCK() first.
   21  */
   22 void stats_prefix_clear(void);
   23 
   24 /* Record a GET for a key */
   25 void stats_prefix_record_get(const char *key, const size_t nkey, const bool is_hit);
   26 
   27 /* Record a DELETE for a key */
   28 void stats_prefix_record_delete(const char *key, const size_t nkey);
   29 
   30 /* Record a SET for a key */
   31 void stats_prefix_record_set(const char *key, const size_t nkey);
   32 
   33 /* Return the collected stats in a textual for suitable for writing to a client.
   34  * The size of the output text is stored in the length parameter.
   35  * Returns NULL on error
   36  */
   37 char *stats_prefix_dump(int *length);
   38 
   39 /* Visible for testing */
   40 #define PREFIX_HASH_SIZE 256
   41 typedef struct _prefix_stats PREFIX_STATS;
   42 struct _prefix_stats {
   43     char *prefix;
   44     size_t prefix_len;
   45     uint64_t num_gets;
   46     uint64_t num_sets;
   47     uint64_t num_deletes;
   48     uint64_t num_hits;
   49     PREFIX_STATS *next;
   50 };
   51 
   52 /* Return the PREFIX_STATS structure for the specified key, creating it if
   53  * it does not already exist. Returns NULL if the key does not contain
   54  * prefix delimiter, or if there was an error. Requires you to have acquired
   55  * STATS_LOCK() first.
   56  */
   57 PREFIX_STATS *stats_prefix_find(const char *key, const size_t nkey);
   58 
   59 #endif