ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - mdaliyan/icache: A High Performance, Generic, thread-safe, zero-dependency, key-value, in-memory cache
A High Performance, Generic, thread-safe, zero-dependency, key-value, in-memory cache - mdaliyan/icache
Visit Site

GitHub - mdaliyan/icache: A High Performance, Generic, thread-safe, zero-dependency, key-value, in-memory cache

GitHub - mdaliyan/icache: A High Performance, Generic, thread-safe, zero-dependency, key-value, in-memory cache

icache

example workflow Coverage Status Go Report Card Go Reference License

icache is a no-dependency, generic support cache library for Go with high concurrent access performance. icache doean't require serialization, so the benchmark report you see at the bottom of the page is what you get at the end, there is no need to marshal and unmarshal anything and waste your valuable resources.

Features

  • Thread safe: icache stores the data in multiple shards and uses a separate mutex for each shard.
  • Generics: Using generics makes it type-safe.
  • Tags: icache supports tags for entries and entries with the shared tags can be dropped at the same time.
  • Pointer friendly: icache stores data as is. any object can be stored in icache, even pointers.
  • TTL: ttl can be set to any thing from 1 seconds to infinity.

Installation

icache v2 requires go v1.8.0 and above.

go get github.com/mdaliyan/icache/v2

previous version for Go < 1.18

icache v1 is compatible with Go < 1.18, and it also doean't require serialization. it uses reflections to make sure about your data type.

Follow instructions at version v1.x.x for installation and usage. V1 will be maintained separately.

Usage

// make a new Pot:
// - to store user structs 
// - with expiration time of 1 Hour
var pot = icache.NewPot[user](
          icache.WithTTL(time.Hour),
    )

var User = user{
    ID:   "foo",
    Name: "John Doe",
    Age:  30,
}

// set user to "foo" key
pot.Set("foo", User)

// get the user previously set to "foo" key into user1 
user1, err := pot.Get("foo")

// you also can add tags to your entries
pot.Set("foo", User, "tag1", "tag2")
pot.Set("faa", User, "tag1")
pot.Set("fom", User, "tag3")

// and delete multiple entries at once
pot.DropTags("tag1")

Invalidation Strategies

  • By Key
  • By Tag
  • By TTL: Using the WithTTL() option.

Benchmarks

goos: darwin
goarch: amd64
pkg: github.com/mdaliyan/icache/v2
cpu: Intel(R) Core(TM) i7-8557U CPU @ 1.70GHz
BenchmarkICache
BenchmarkICache-8             	9570999	    118.1 ns/op	   0 B/op	  0 allocs/op
BenchmarkICacheConcurrent
BenchmarkICacheConcurrent-8   	6117471	    191.4 ns/op	   0 B/op	  0 allocs/op

Plans for later

  • Different invalidation Strategies can be added if it's needed.
  • Maybe Remote sync

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory