# README
Not for production use and not recommended for large datasets!
This db2
package provides basic functions for managing
key-value pairs stored in a JSON file.
Important:
Call LoadCache(path string)
at the start of your main
function to initialize the cache with the JSON file located at
path
, and defer SaveCache()
to save changes
when the program exits. You can simply call SaveCache()
after any AddToCache()
statment if preferred over saving cache on shutdown.
Functions:
1. LoadCache(path string):
Loads the cache from the specified JSON file. Call this at the start of your
main function.
2. SaveCache():
Saves the cache to the JSON file. Defer this at the start of your main
function.
3. AddToCache(key string, value map[string]interface{}):
Adds a value to the cache under the specified key.
4. SearchCache[T any](key string, field string, search T)
map[string]interface{}:
Searches the cache for an item matching the specified key and field. Returns
the first matching item.
5. DeleteFromCache[T any](key string, field string, search T):
Deletes an item from the cache based on the specified key and field.
Returns the full cache for the specified key.
Example Usage:
View example/main.go
for more details.