Package: hermescloud
HermesGo Installgo get github.com/realTristan/HermesPython Installpip install hermescloudWhat is Hermes?Hermes is an extremely fast full-text search algorithm and caching system written in Go. It's designed for API implementations which can be used by wrappers in other languages.
Hermes has two notable algorithms. The first being the with-cache algorithm. When using the with-cache algorithm, you can set, get, store, etc. keys and values into the cache. The second
being a no-cache algorithm that reads data from a map, or json file, and uses and array to store the data. Both of these algorithms provide full-text search query times from 10µs to 300µs.Example of NoCache Full-Text-SearchIf you want to use only the full-text-search features, then just import hermes and load it using a .json file. (as shown in /example). Note: For small to medium-sized datasets (like the ones I used in /data), Hermes works great. Although, as the words in the dataset increases, the full-text-search cache will take up significantly more memory.BenchmarksDataset Map Entries: 4,115
Dataset Total Words: 208,092
Dataset Map Size: ≈ 2.3MB

Query: Computer, Limit: 100, Strict: False => 36.5µs
Query: Computer, Limit: 100, Strict: True => 12.102µsCodepackagemainimport("fmt""time"Hermes"github.com/realTristan/Hermes/nocache")funcmain(){// Initialize the full-text cachevarft,_=Hermes.InitWithJson("data.json")// Create a schema. These are the fields that will be searched.varschema=map[string]bool{"name":true,"id":false,}// Search for a word in the cache// @params: query, limit, strictvarres,_=ft.Search("tristan",100,false,schema)fmt.Println(res)}data.json[{"id":1,"name":{"$hermes.full_text":true,"$hermes.value":"Tristan Simpson"},},]Example of Cache Full-Text-SearchThe full-text-search from /cache is significantly slower than the nocache FTS. Why? Because the FTS in /cache requires more memory, keys, and utilizes a map instead of a slice to store data. If you want to use a cache along with the full text-search algorithm, import the files from /cache. To setup a cache, check out /cache/example or /cache/testing.BenchmarksDataset Map Entries: 4,115
Dataset Total Words: 208,092
Dataset Map Size: ≈ 2.3MB

Query: Computer, Limit: 100, Strict: False => 263.7µs
Query: Computer, Limit: 100, Strict: True => 40.84µsCodepackagemainimport("fmt""time"Hermes"github.com/realTristan/Hermes")funcmain(){// Initialize the cachevarcache*Hermes.Cache=Hermes.InitCache()// Initialize the full-text cache// MaxLength: 10, MaxBytes: -1 (no limit)cache.FTInit(10,-1)// Set the value in the cachecache.Set("user_id",map[string]interface{}{"name":Hermes.WithFT("tristan"),"age":17,"expiration":time.Now(),})// The keys you want to search through in the full-text searchvarschemamap[string]bool=map[string]bool{"name":true,"age":false,"expiration":false,}// Search for a word in the cache and print the resultvarresult,_=cache.Search("tristan",100,false,schema)fmt.Println(result)}data.jsonUsed with cache.FTInitWithJson(){"user_id":{"age":17,"name":{"$hermes.full_text":true,"$hermes.value":"Tristan Simpson"},},}Hermes Cloud AppInstallComing SoonCustom Implementationimport("github.com/gofiber/fiber/v2"Hermes"github.com/realTristan/Hermes"Socket"github.com/realTristan/Hermes/socket")funcmain(){// Cache and fiber appcache:=Hermes.InitCache()app:=fiber.New()// Set the routerSocket.SetRouter(app,cache)// Listen on port 3000app.Listen(":3000")}Websocket APICachecache.setAboutSet a value in the cache with the corresponding key.Example Request{"function":"cache.set","key":"user_id","value":base64{"name":"tristan"}}Response{"success":true/false,"data":nil}cache.deleteAboutDelete the provided key, and the data correlated to it from the cache.Example Request{"function":"cache.delete","key":"user_id"}Response{"success":true/false,"data":nil}cache.getAboutGet data from the cache using a key.Example Request{"function":"cache.get","key":"user_id"}Response{"success":true/false,"data":map[string]any}cache.keysAboutGet all of the keys in the cache.Example Request{"function":"cache.keys"}Response{"success":true/false,"data":[]string}cache.valuesAboutGet all of the values in the cache.Example Request{"function":"cache.values"}Response{"success":true/false,"data":[]map[string]any}cache.lengthAboutGet the amount of keys stored in the cache.Example Request{"function":"cache.length"}Response{"success":true/false,"data":int}cache.cleanAboutClean all the data in the cache, and full-text storage.Example Request{"function":"cache.clean"}Response{"success":true/false,"data":nil}cache.infoAboutGet the cache and full-text storage statistics.Example Request{"function":"cache.info"}Response{"success":true/false,"data":string}cache.existsAboutGet whether a key exists in the cache.Example Request{"function":"cache.exists","key":"user_id"}Response{"success":true/false,"data":bool}Full-Textft.initAboutIntialize the full text cache.Example Request{"function":"ft.init","maxbytes":-1,"maxlength":-1}Response{"success":true/false,"data":nil}ft.cleanAboutClean all of the data in the full-text storage.Example Request{"function":"ft.clean"}Response{"success":true/false,"data":nil}ft.searchAboutSearch for a query in the full-text storage.Example Request{"function":"ft.search","query":"tristan","strict":false,"limit":10,"schema":{"key":true}}Response{"success":true/false,"data":[]map[string]any}ft.search.onewordAboutSearch for a single word in the full-text storage.Example Request{"function":"ft.search.oneword","query":"tristan","strict":false,"limit":10}Response{"success":true/false,"data":[]map[string]any}ft.search.valuesAboutSearch in the cache data values. (Slower)Example Request{"function":"ft.search.values","query":"tristan","limit":10,"schema":{"key":true}}Response{"success":true/false,"data":[]map[string]any}ft.search.withkeyAboutSearch in the cache data values for a specific key.Example Request{"function":"ft.search.withkey","query":"tristan","key":"user_id","limit":10}Response{"success":true/false,"data":[]map[string]any}ft.maxbytes.setAboutSet the maximum full-text storage size in bytes.Example Request{"function":"ft.maxbytes.set","maxbytes":-1}Response{"success":true/false,"data":nil}ft.maxlength.setAboutSet the maximum full-text storage words allowed to be stored.Example Request{"function":"ft.maxlength.set","maxlength":-1}Response{"success":true/false,"data":nil}ft.storageAboutGet the current full-text storage.Example Request{"function":"ft.storage"}Response{"success":true/false,"data":map[string][]int}ft.storage.sizeAboutGet the current full-text storage size in bytes.Example Request{"function":"ft.storage.size"}Response{"success":true/false,"data":int}ft.storage.lengthAboutGet the current full-text storage length.Example Request{"function":"ft.storage.length"}Response{"success":true/false,"data":int}ft.isinitializedAboutGet whether the full-text storage has been initialized.Example Request{"function":"ft.isinitialized"}Response{"success":true/false,"data":bool}ft.indices.sequenceAboutSequence the full-text storage indices.Example Request{"function":"ft.indices.sequence"}Response{"success":true/false,"data":nil}To-doTesting FilesMore DocumentationMore ExamplesWrappers for other languagesLicenseMIT LicenseCopyright (c) 2023 TristanPermission 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.