jaredwray/cacheable

Cache value automatically serialized

Closed this issue · 1 comments

Hi!

First : Very good project!!
Can you add an option to not serialize the cache value by default? My cache file is like it:

{
    "entries": [
        {
            "key": "cacheable-request:GET:http://[My url]",
            "content": "{\"value\":{\"cachePolicy\":{\"v\":1,\"t\":1636958507292,\"sh\":true,\"ch\":0.1,\"imm\":86400000,\"st\":200,\"resh\":{\"date\":\"Mon, 15 Nov 2021 06:41:47 GMT\",\"server\":\"Apache-Coyote/1.1\",\"x-frame-options\":\"SAMEORIGIN, SAMEORIGIN\",\"cache-control\":\"no-cache, max-age=0\",\"content-type\":\"application/json;charset=UTF-8\",\"vary\":\"Accept-Encoding,Origin\",\"connection\":\"close\",\"transfer-encoding\":\"chunked\"},\"rescc\":{\"no-cache\":true,\"max-age\":\"0\"},\"m\":\"GET\",\"a\":true,\"reqh\":{\"key\":\"-- my internal headers --\"},\"reqcc\":{}},\"url\":\"\",\"statusCode\":200,\"body\":\":base64:[the base 64 content]\"}}"
        }
    ]
}

The content is the value when the lib call "cache.set(key, value)". We can see two things :

  1. The value is already JSON serialized
  2. The body is automatically base-64 encoded

It will be very perfect if (1) and (2) can be bypassed. I want to see the content of cache with simple text editor for debug. I can do it before store the value, but i'm afraid to create a bug in the future if API is updated.

Regards.

@Chklang - sorry as this is a function of our Keyv and we do not plan to change this.

If you want you can do your own json-serializer in Keyv to replace it.