Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
BoltDB and Badger are the most popular options. If you don't want to use a third-party package you'll have to reinvent it. Still, you can use one of these two as examples. You'll also find plenty of tutorials online, like this one.
I will agree with built in maps, badger, and bbolt as previously mentioned. Some unique cases require that you do many read. Take a look at the design of https://github.com/akrylysov/pogreb.
There's a great wrapper library around bolt (and badger, by the same guy): https://github.com/timshannon/bolthold
There are also different packages used as a wrapper on top of the Go map based on what your requirements are (storing a lot of data) https://github.com/allegro/bigcache or (need performance) https://github.com/dgraph-io/ristretto. For basic use-cases, the standard Go map should be enough. Just keep in mind whether you need concurrent access to your data structure, in which case you should guard your map with a mutex .
There are also different packages used as a wrapper on top of the Go map based on what your requirements are (storing a lot of data) https://github.com/allegro/bigcache or (need performance) https://github.com/dgraph-io/ristretto. For basic use-cases, the standard Go map should be enough. Just keep in mind whether you need concurrent access to your data structure, in which case you should guard your map with a mutex .
Related posts
- Otter, Fastest Go in-memory cache based on S3-FIFO algorithm
- imcache v1.0.0 released. A zero-dependency generic in-memory cache Go library.
- rueidis v1, a redis client with client-side caching, has been released under redis org
- Theine - High performance in-memory cache
- [imcache] A generic in-memory cache Go library. Feedback appreciated.