{"id":13573726,"url":"https://github.com/realTristan/Hermes","last_synced_at":"2025-04-04T12:31:24.835Z","repository":{"id":152565953,"uuid":"626155659","full_name":"realTristan/hermes","owner":"realTristan","description":"Extremely Fast Full-Text-Search Algorithm and Caching System","archived":false,"fork":false,"pushed_at":"2023-07-19T16:46:53.000Z","size":53876,"stargazers_count":152,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-03-14T15:50:57.123Z","etag":null,"topics":["algorithm","cache","fast","full-text-search","go"],"latest_commit_sha":null,"homepage":"https://realtristan.github.io/hermes/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/realTristan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-04-10T23:08:19.000Z","updated_at":"2024-02-09T16:17:02.000Z","dependencies_parsed_at":"2024-01-14T04:44:38.313Z","dependency_job_id":null,"html_url":"https://github.com/realTristan/hermes","commit_stats":null,"previous_names":[],"tags_count":73,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realTristan%2Fhermes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realTristan%2Fhermes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realTristan%2Fhermes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realTristan%2Fhermes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/realTristan","download_url":"https://codeload.github.com/realTristan/hermes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246899658,"owners_count":20851898,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","cache","fast","full-text-search","go"],"created_at":"2024-08-01T15:00:40.322Z","updated_at":"2025-04-04T12:31:24.804Z","avatar_url":"https://github.com/realTristan.png","language":"Go","funding_links":[],"categories":["Programming"],"sub_categories":["Golang"],"readme":"# Hermes ![Stars](https://img.shields.io/github/stars/realTristan/hermes?color=brightgreen) ![Watchers](https://img.shields.io/github/watchers/realTristan/hermes?label=Watchers)\n\u003cimg width=\"1173\" alt=\"Screenshot 2023-06-03 at 1 55 31 PM\" src=\"https://github.com/realTristan/hermes/assets/75189508/f884f643-00af-405d-900d-a636d119cf74\"\u003e\n\n# How to contribute\nHermes is still in a developmental phase. Helping with test cases, benchmarks, speed, and memory usage are a great way to contribute to the project.\n\n## Hermes Go\nDirect access to the hermes cache/nocache functions.\n```\ngo get github.com/realTristan/hermes\n```\n\n## Hermes Cloud\nAccess the hermes cache functions via websocket.\n\n### Python\n```\npip install hermescloud\n```\n\n# What is Hermes?\nHermes is an extremely fast full-text search and caching framework written in Go.\nHermes has a cache algorithm where you can set, get, store, etc. keys and values into the cache, and a no-cache algorithm that reads data from an array or json file and uses an array to store data. Both of these algorithms provide full-text search query speeds from 10µs to 300µs.\n\n# Example of NoCache\nIf you want to use only the full-text-search features, then import hermes/nocache. Load the data using a .json file or array of maps. No Cache is much faster than the With-Cache algorithm, but you can't update the data.\n\n## Code\n```go\npackage main\n\nimport (\n  \"fmt\"\n  \"time\"\n\n  hermes \"github.com/realTristan/hermes/nocache\"\n)\n\nfunc main() {\n  // Initialize the full-text cache\n  var ft, _ = hermes.InitWithJson(\"data.json\")\n\n  // Search for a word in the cache\n  var res, _ = ft.Search(hermes.SearchParams{\n    Query:  \"tristan\",\n    Limit:  100,\n    Strict: false,\n  })\n\n  fmt.Println(res)\n}\n```\n\n### Benchmarks\n```\nDataset Map Entries: 4,115\nDataset Total Words: 208,092\nDataset Map Size: ≈ 2.3MB\n\nQuery: Computer, Limit: 100, Strict: False =\u003e 36.5µs\nQuery: Computer, Limit: 100, Strict: True =\u003e 12.102µs\n```\n\n### data.json\nUsed with hermes.InitWithJson()\n```json\n[\n  {\n    \"id\": 1,\n    \"name\": {\n      \"$hermes.full_text\": true,\n      \"$hermes.value\": \"Tristan Simpson\"\n    },\n  },\n]\n```\n\n# With-Cache Example\nThe with-cache algorithm is notably slower than the no-cache algorithm. Why? Because the with-cache algorithm uses maps to store data and not an array. Import hermes directly to use the with-cache features.\n\n## Code\n```go\npackage main\n\nimport (\n  \"fmt\"\n  \"time\"\n  hermes \"github.com/realTristan/hermes\"\n)\n\nfunc main() {\n  // Initialize the cache\n  cache := hermes.InitCache()\n\n  // MaxSize: 10, MaxBytes: -1 (no limit), MinWordLength: 3\n  cache.FTInit(10, -1, 3)\n\n  // Set the value in the cache\n  cache.Set(\"user_id\", map[string]any{\n    \"name\":       cache.WithFT(\"tristan\"),\n    \"age\":        17,\n  })\n\n  // Search for a word in the cache and print the result\n  result, err := cache.Search(hermes.SearchParams{\n    Query:  \"tristan\",\n    Limit:  100,\n    Strict: false,\n  })\n\n  fmt.Println(result)\n}\n```\n\n### Benchmarks\n```\nDataset Map Entries: 4,115\nDataset Total Words: 208,092\nDataset Map Size: ≈ 2.3MB\n\nQuery: Computer, Limit: 100, Strict: False =\u003e 263.7µs\nQuery: Computer, Limit: 100, Strict: True =\u003e 40.84µs\n```\n\n### data.json\nUsed with cache.FTInitWithJson()\n```json\n{\n  \"user_id\": {\n    \"age\": 17,\n    \"name\": {\n      \"$hermes.full_text\": true,\n      \"$hermes.value\": \"Tristan Simpson\"\n    },\n  },\n}\n```\n\n# Hermes Cloud App\n## Install\n```\nComing Soon\n```\n\n## Custom Implementation\n```go\nimport (\n  \"github.com/gofiber/fiber/v2\"\n  hermes \"github.com/realTristan/hermes\"\n  socket \"github.com/realTristan/hermes/cloud/socket\"\n)\n\nfunc main() {\n  // Cache and fiber app\n  cache := hermes.InitCache()\n  app := fiber.New()\n\n  // Set the router\n  socket.SetRouter(app, cache)\n\n  // Listen on port 3000\n  app.Listen(\":3000\")\n}\n```\n\n# Websocket API\n## Cache\n\n### [cache.set](https://github.com/realTristan/hermes/blob/master/cloud/socket/handlers/set.go)\n\n#### About\n```\nSet a value in the cache with the corresponding key.\n```\n\n#### Example Request\n```go\n{\n  \"function\": \"cache.set\",\n  \"key\": \"user_id\",\n  \"value\": base64{\n    \"name\": \"tristan\"\n  }\n}\n```\n\n#### Response\n```go\n{\n  \"success\": true/false, \n  \"data\": nil\n}\n```\n\n### [cache.delete](https://github.com/realTristan/hermes/blob/master/cloud/socket/handlers/delete.go)\n\n#### About\n```\nDelete the provided key, and the data correlated to it from the cache.\n```\n\n#### Example Request\n```go\n{\n  \"function\": \"cache.delete\",\n  \"key\": \"user_id\"\n}\n```\n\n#### Response\n```go\n{\n  \"success\": true/false, \n  \"data\": nil\n}\n```\n\n### [cache.get](https://github.com/realTristan/hermes/blob/master/cloud/socket/handlers/get.go)\n\n#### About\n```\nGet data from the cache using a key.\n```\n\n#### Example Request\n```go\n{\n  \"function\": \"cache.get\",\n  \"key\": \"user_id\"\n}\n```\n\n#### Response\n```go\n{\n  \"success\": true/false, \n  \"data\": map[string]any\n}\n```\n\n### [cache.keys](https://github.com/realTristan/hermes/blob/master/cloud/socket/handlers/keys.go)\n\n#### About\n```\nGet all of the keys in the cache.\n```\n\n#### Example Request\n```go\n{\n  \"function\": \"cache.keys\"\n}\n```\n\n#### Response\n```go\n{\n  \"success\": true/false, \n  \"data\": []string\n}\n```\n\n### [cache.values](https://github.com/realTristan/hermes/blob/master/cloud/socket/handlers/values.go)\n\n#### About\n```\nGet all of the values in the cache.\n```\n\n#### Example Request\n```go\n{\n  \"function\": \"cache.values\"\n}\n```\n\n#### Response\n```go\n{\n  \"success\": true/false, \n  \"data\": []map[string]any\n}\n```\n\n### [cache.length](https://github.com/realTristan/hermes/blob/master/cloud/socket/handlers/length.go)\n\n#### About\n```\nGet the amount of keys stored in the cache.\n```\n\n#### Example Request\n```go\n{\n  \"function\": \"cache.length\"\n}\n```\n\n#### Response\n```go\n{\n  \"success\": true/false, \n  \"data\": int\n}\n```\n\n### [cache.clean](https://github.com/realTristan/hermes/blob/master/cloud/socket/handlers/clean.go)\n\n#### About\n```\nClean all the data in the cache, and full-text storage.\n```\n\n#### Example Request\n```go\n{\n  \"function\": \"cache.clean\"\n}\n```\n\n#### Response\n```go\n{\n  \"success\": true/false, \n  \"data\": nil\n}\n```\n\n### [cache.info](https://github.com/realTristan/hermes/blob/master/cloud/socket/handlers/info.go)\n\n#### About\n```\nGet the cache and full-text storage statistics.\n```\n\n#### Example Request\n```go\n{\n  \"function\": \"cache.info\"\n}\n```\n\n#### Response\n```go\n{\n  \"success\": true/false, \n  \"data\": string\n}\n```\n\n### [cache.exists](https://github.com/realTristan/hermes/blob/master/cloud/socket/handlers/exists.go)\n\n#### About\n```\nGet whether a key exists in the cache.\n```\n\n#### Example Request\n```go\n{\n  \"function\": \"cache.exists\",\n  \"key\": \"user_id\"\n}\n```\n\n#### Response\n```go\n{\n  \"success\": true/false, \n  \"data\": bool\n}\n```\n\n## Full-Text\n\n### [ft.init](https://github.com/realTristan/hermes/blob/master/cloud/socket/handlers/init.go)\n\n#### About\n```\nIntialize the full text cache.\n```\n\n#### Example Request\n```go\n{\n  \"function\": \"ft.init\",\n  \"maxbytes\": -1,\n  \"maxsize\": -1,\n  \"minwordlength\": 3\n}\n```\n\n#### Response\n```go\n{\n  \"success\": true/false, \n  \"data\": nil\n}\n```\n\n### [ft.clean](https://github.com/realTristan/hermes/blob/master/cloud/socket/handlers/clean.go)\n\n#### About\n```\nClean all of the data in the full-text storage.\n```\n\n#### Example Request\n```go\n{\n  \"function\": \"ft.clean\"\n}\n```\n\n#### Response\n```go\n{\n  \"success\": true/false, \n  \"data\": nil\n}\n```\n\n### [ft.search](https://github.com/realTristan/hermes/blob/master/cloud/socket/handlers/search.go)\n\n#### About\n```\nSearch for a query in the full-text storage.\n```\n\n#### Example Request\n```go\n{\n  \"function\": \"ft.search\",\n  \"query\": \"tristan\",\n  \"strict\": false,\n  \"limit\": 10\n}\n```\n\n#### Response\n```go\n{\n  \"success\": true/false, \n  \"data\": []map[string]any\n}\n```\n\n### [ft.search.oneword](https://github.com/realTristan/hermes/blob/master/cloud/socket/handlers/search.go)\n\n#### About\n```\nSearch for a single word in the full-text storage.\n```\n\n#### Example Request\n```go\n{\n  \"function\": \"ft.search.oneword\",\n  \"query\": \"tristan\",\n  \"strict\": false,\n  \"limit\": 10\n}\n```\n\n#### Response\n```go\n{\n  \"success\": true/false, \n  \"data\": []map[string]any\n}\n```\n\n### [ft.search.values](https://github.com/realTristan/hermes/blob/master/cloud/socket/handlers/search.go)\n\n#### About\n```\nSearch in the cache data values. (Slower)\n```\n\n#### Example Request\n```go\n{\n  \"function\": \"ft.search.values\",\n  \"query\": \"tristan\",\n  \"limit\": 10,\n  \"schema\": {\n    \"key\": true\n  }\n}\n```\n\n#### Response\n```go\n{\n  \"success\": true/false, \n  \"data\": []map[string]any\n}\n```\n\n### [ft.search.withkey](https://github.com/realTristan/hermes/blob/master/cloud/socket/handlers/search.go)\n\n#### About\n```\nSearch in the cache data values for a specific key.\n```\n\n#### Example Request\n```go\n{\n  \"function\": \"ft.search.withkey\",\n  \"query\": \"tristan\",\n  \"key\": \"user_id\",\n  \"limit\": 10\n}\n```\n\n#### Response\n```go\n{\n  \"success\": true/false, \n  \"data\": []map[string]any\n}\n```\n\n### [ft.maxbytes.set](https://github.com/realTristan/hermes/blob/master/cloud/socket/handlers/fulltext.go)\n\n#### About\n```\nSet the maximum full-text storage size in bytes.\n```\n\n#### Example Request\n```go\n{\n  \"function\": \"ft.maxbytes.set\",\n  \"maxbytes\": -1\n}\n```\n\n#### Response\n```go\n{\n  \"success\": true/false, \n  \"data\": nil\n}\n```\n\n### [ft.maxsize.set](https://github.com/realTristan/hermes/blob/master/cloud/socket/handlers/fulltext.go)\n\n#### About\n```\nSet the maximum full-text storage words allowed to be stored.\n```\n\n#### Example Request\n```go\n{\n  \"function\": \"ft.maxsize.set\",\n  \"maxsize\": -1\n}\n```\n\n#### Response\n```go\n{\n  \"success\": true/false, \n  \"data\": nil\n}\n```\n\n### [ft.storage](https://github.com/realTristan/hermes/blob/master/cloud/socket/handlers/fulltext.go)\n\n#### About\n```\nGet the current full-text storage.\n```\n\n#### Example Request\n```go\n{\n  \"function\": \"ft.storage\"\n}\n```\n\n#### Response\n```go\n{\n  \"success\": true/false, \n  \"data\": map[string][]int\n}\n```\n\n### [ft.storage.size](https://github.com/realTristan/hermes/blob/master/cloud/socket/handlers/fulltext.go)\n\n#### About\n```\nGet the current full-text storage size in bytes.\n```\n\n#### Example Request\n```go\n{\n  \"function\": \"ft.storage.size\"\n}\n```\n\n#### Response\n```go\n{\n  \"success\": true/false, \n  \"data\": int\n}\n```\n\n### [ft.storage.length](https://github.com/realTristan/hermes/blob/master/cloud/socket/handlers/fulltext.go)\n\n#### About\n```\nGet the current full-text storage length.\n```\n\n#### Example Request\n```go\n{\n  \"function\": \"ft.storage.length\"\n}\n```\n\n#### Response\n```go\n{\n  \"success\": true/false, \n  \"data\": int\n}\n```\n\n### [ft.isinitialized](https://github.com/realTristan/hermes/blob/master/cloud/socket/handlers/fulltext.go)\n\n#### About\n```\nGet whether the full-text storage has been initialized.\n```\n\n#### Example Request\n```go\n{\n  \"function\": \"ft.isinitialized\"\n}\n```\n\n#### Response\n```go\n{\n  \"success\": true/false, \n  \"data\": bool\n}\n```\n\n### [ft.indices.sequence](https://github.com/realTristan/hermes/blob/master/cloud/socket/handlers/indices.go)\n\n#### About\n```\nSequence the full-text storage indices.\n```\n\n#### Example Request\n```go\n{\n  \"function\": \"ft.indices.sequence\"\n}\n```\n\n#### Response\n```go\n{\n  \"success\": true/false, \n  \"data\": nil\n}\n```\n\n# To-do\n- Testing Files\n- More Documentation\n- More Examples\n- Wrappers for other languages\n\n# License\nMIT License\n\nCopyright (c) 2023 Tristan\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FrealTristan%2FHermes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FrealTristan%2FHermes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FrealTristan%2FHermes/lists"}