Categorygithub.com/devkaare/db2
modulepackage
0.0.0-20240608230001-0cb3ff47f51e
Repository: https://github.com/devkaare/db2.git
Documentation: pkg.go.dev

# 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.

6. GetCache(key string) []interface{}:
Returns the full cache for the specified key.

Example Usage:

View example/main.go for more details.

# Packages

No description provided by the author

# Functions

No description provided by the author
No description provided by the author
This function is not intended to be used outside this file, hence not included in docs.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author