|
| 1 | +# Lawn API |
| 2 | + |
| 3 | +## Lawn Auditing |
| 4 | +`Lawn* newLawn(void);` |
| 5 | + |
| 6 | +Create a new Lawn timer store. |
| 7 | + |
| 8 | + |
| 9 | +`void freeLawn(Lawn* dehy);` |
| 10 | + |
| 11 | +Free all data and memory of a Lawn data store |
| 12 | + |
| 13 | + |
| 14 | +`size_t ttl_count(Lawn* dehy);` |
| 15 | + |
| 16 | +Return the number of uniqe ttl entries in the lawn |
| 17 | + |
| 18 | + |
| 19 | +`mstime_t next_at(Lawn* dehy);` |
| 20 | + |
| 21 | +Return the closest element expiration datetime (in milliseconds), or -1 if DS is empty |
| 22 | + |
| 23 | + |
| 24 | +## TTL Manipulation |
| 25 | + |
| 26 | +`int set_element_ttl(Lawn* dehy, char* element, size_t len, mstime_t ttl_ms);` |
| 27 | + |
| 28 | +Insert ttl for a new element or update an existing one. Returns DHY_OK on success, DHY_ERR on error. |
| 29 | + |
| 30 | +`mstime_t get_element_exp(Lawn* dehy, char* element);` |
| 31 | + |
| 32 | +Get the expiration value for the given element. Returns datetime of expiration (in milliseconds) on success, -1 on error |
| 33 | + |
| 34 | + |
| 35 | +`int del_element_exp(Lawn* dehy, char* element);` |
| 36 | + |
| 37 | +Remove TTL from the lawn for the given element. Returns `DHY_OK` |
| 38 | + |
| 39 | + |
| 40 | +`char* pop_next(Lawn* dehy);` |
| 41 | + |
| 42 | +Remove and return the element with the closest expiration datetime |
| 43 | + |
| 44 | + |
| 45 | +`ElementQueue* pop_expired(Lawn* dehy);` |
| 46 | + |
| 47 | +return a queue of all exired element nodes. |
| 48 | + |
| 49 | + |
| 50 | +## QUEUE UTILITIES |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | +`void freeQueue(ElementQueue* queue);` |
| 59 | + |
| 60 | +Free all data and memory of a queue retuned from the `pop_expired` method. |
| 61 | + |
| 62 | + |
| 63 | +`void queuePush(ElementQueue* queue, ElementQueueNode* node);` |
| 64 | + |
| 65 | +Add a given `ElementQueueNode` to a queue retuned from the `pop_expired` method. |
| 66 | + |
| 67 | + |
| 68 | +`ElementQueueNode* queuePop(ElementQueue* queue);` |
| 69 | + |
| 70 | +Remove and return the first `ElementQueueNode` from a queue retuned from the `pop_expired` method. |
| 71 | + |
| 72 | + |
| 73 | +## ELEMENT NODE UTILITIES |
| 74 | + |
| 75 | +`ElementQueueNode* NewNode(char* element, size_t element_len, mstime_t ttl);` |
| 76 | + |
| 77 | +Create an `ElementQueueNode`. |
| 78 | + |
| 79 | +`void freeNode(ElementQueueNode* node);` |
| 80 | + |
| 81 | +Free all data and memory of an `ElementQueueNode`. |
0 commit comments