karlseguin / ccache

A golang LRU Cache for high concurrency
MIT License
1.28k stars 119 forks source link

Can't seem to figure out how layeredcache works because it doesnt work. #19

Closed unisqu closed 5 years ago

unisqu commented 5 years ago

why doesnt the below work? also, am i doing it right? i've tried multiple different ways. there's no error shown... pls help thx.

i realised it seems to stuck at displaying the value... if not initialized. how do i resolve? I think (int) for nil will jam without error displayed

     package httpcachetesting

     import (
           "github.com/karlseguin/ccache"
           "fmt"
      )

   var (
            HttpContentCache = ccache.Layered(ccache.Configure())
     )

    func HTTPCacheGet(urlhost string, urlreq string) (int, []byte, []byte, int, bool) {

              fmt.Printf("*** Start\n")
             httpcaches := HttpContentCache.Get(urlhost, "s"+urlreq) //same as stored in redis

              fmt.Printf("*** THIS MSG IS NOT SHOWING?!?!?! V : %v\n", httpcaches.Value().(int))

     }
unisqu commented 5 years ago

i resolved it. needed to do type assertion. thx. great software.