Skip to content

Latest commit

 

History

History
59 lines (42 loc) · 949 Bytes

README.md

File metadata and controls

59 lines (42 loc) · 949 Bytes

key value in memory store

safe concurrent key value in memory store

install:

go get github.com/baxiry/kv 

usage:

package main

import (
      "github.com/baxiry/kv"
)

func main() {
      imap := new(kv.Map[int, int])

      imap.Set(1, 111) // insert
      imap.Set(1, 123) // update

      imap.Set(2, 222)

      val, ok := imap.Get(1) //  123 , treu
      val, ok = imap.Get(10) //  0, false (key not exist)
 
      ok := imap.HasKey(2) //  true
      ok = imap.HasKey(20) //  false

      imap.Delete(2)

      ok = imap.HasKey(2) // false

      // new stringer Map 
      strMap := new(kv.Map[string, string])

      strMap.Set("hi", "hello")
}

TODO:

  • Set
  • Get
  • HasKey
  • Delete
  • full testing.

not important

  • auto delete by timeout.
  • benchmark.
  • avoid pointers as mach as posible for more gc effecion.

license:

use it with any license you prefer