Better Cache

Lightning Fast Caching System for Go.
About
- Better Cache is an ultra fast caching system that uses an array of bytes for storing data instead of the very common map caching system. Because the data is stored in an array of bytes instead of a map, it allows the user to achieve lightning fast full text search speeds. (within microseconds to milliseconds)
- Better Cache also only uses native golang modules which makes it fast, lightweight and easy to use.
Benchmarks
Full Text Search
(1) Cache Size: 25 -> ~42µs
(10) Cache Size: 250 -> ~82µs
(100) Cache Size: 2,500 -> ~220µs
(1,000) Cache Size: 25,000 -> ~1.63ms
(10,000) Cache Size: 250,000 -> ~16.87ms
Quick Usage
package main
import (
"fmt"
"github.com/realTristan/BetterCache"
)
func main() {
// Add key1 to the cache
cache.Set("key1", map[string]string{
"summary": "My name is \"Tristan\"",
})
// Get key from the cache
var data = cache.Get("key1")
fmt.Println(data)
// Full Text Search for the key's contents
var res = cache.FullTextSearch(TextSearch{
Limit: -1,
Query: []byte("Tristan"),
StrictMode: false,
})
fmt.Println(res)
// Remove key1 from the cache
cache.Remove("key1")
}
License
MIT License
Copyright (c) 2022 Tristan Simpson
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.