mailgun / groupcache

Clone of golang/groupcache with TTL and Item Removal support
Apache License 2.0
484 stars 72 forks source link

Example from cmd/server does not work as expected #71

Open ashumkin opened 1 month ago

ashumkin commented 1 month ago

I run

go run  cmd/server/main.go

server starts, outputs

Running...

Then I run

curl 'localhost:8081/set?key=a&value=1'

server outputs

Set: [a]1

then I run

curl 'localhost:8081/cache?key=a'

server outputs

Fetching value for key 'a'

curl hangs for a while then outputs

context deadline exceeded

I expect server will output the value 1 set for the key a

ashumkin commented 1 month ago

Also, the same code (with removed expiration time on the line 27 ) works well with the original golang/groupcache package

$ curl 'localhost:8081/set?key=a&value=1' -i
HTTP/1.1 200 OK
Date: Thu, 01 Aug 2024 16:46:31 GMT
Content-Length: 0

$ curl 'localhost:8081/cache?key=a' -i
HTTP/1.1 200 OK
Date: Thu, 01 Aug 2024 16:46:33 GMT
Content-Length: 2
Content-Type: text/plain; charset=utf-8

1