Skip to content
/ goutil Public

reflect goroutine spin_lock async, lazy cache, json reader ,writer

License

Notifications You must be signed in to change notification settings

shuyj/goutil

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#Caffine for go simple

    cache/cache_test.go : TestAsyncNBlockCache
    key := fmt.Sprintf("key_%d", i)
    val, rtime, err := GetWithTime(key)

    if err != nil {
        fmt.Printf("Get error = %v\n", err)
        continue
    }
    if rtime <= 10*time.Millisecond {
        // expired
        // reload asynchronous
        common.Async(func() {
            // get data with key
            fmt.Printf("reload key=%s\n", key)
            SetEx(key, i, 10*time.Second)
        })
    }
    // return cached data whether or not expired
    val=val

About

reflect goroutine spin_lock async, lazy cache, json reader ,writer

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages