MCPcopy Index your code
hub / github.com/stirby/temp

github.com/stirby/temp @v2.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.0.0 ↗ · + Follow
15 symbols 22 edges 6 files 7 documented · 47% 31 cross-repo links updated 2y agov2.0.0 · 2016-07-07★ 38

Browse by type

Functions 10 Types & classes 5
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Temp

Temporary structs and maps with expiring elements in Golang

Table of Contents

Install

go get gopkg.in/ammario/temp.v2

Basic Usage

Temporary struct

type session struct {
    ID string
    temp.T
}

func main() {
    sess := session{}
    temp.ExpireAfter(&sess, time.Second)
    fmt.Printf("Session expired: %v\n", temp.Expired(&sess)) // false
    time.Sleep(time.Second)
    fmt.Printf("Session expired: %v\n", temp.Expired(&sess)) // true
}

Expiring map

m := map[string]*session{
    "123": &session{
        ID: "123",
        temp.T: temp.T{
            expires: time.Now().Add(time.Second),
        },
    },
    "124": &session{
        ID: "124",
        temp.T: temp.T{
            expires: time.Now().Add(time.Second),
        },
    },
    "125": &session{
        ID: "125",
        temp.T: temp.T{
            expires: time.Now().Add(time.Second),
        },
    },
}
mutex := &sync.RWMutex{}
go temp.Clean(m, mutex, time.Millisecond*50, 0) //Clean blocks forever
time.Sleep(time.Second * 2)
//Map should be empty here

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Function 6
Method 4
Struct 4
Interface 1

Languages

Go100%

Modules by API surface

temporary.go5 symbols
t.go3 symbols
temporary_test.go2 symbols
example/main.go2 symbols
clean_test.go2 symbols
clean.go1 symbols

For agents

$ claude mcp add temp \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page