Closed lgrapenthin closed 7 years ago
I can see what that section is confusing. I'll look into getting it updated (probably not before next week), but in the mean time ...
The counter is used to generate different cache codes for each cacheable element. The first one gets a cache code of "^0", the next one is "^1", etc, up to "^[[" (ascii rep of 44^2), after which it starts over at "^0".
next id=42
is just meant to represent the incrementing counter, but it's a confusing example.
Thanks for clarifying. One more question: "#tag, keyword and symbol values, and strings used as map keys are cached if they are longer than 3 characters." Does that mean strings are cached exclusively as map keys and the other mentioned types are always cached? Or only if they are used as map keys, too?
Strings are only cached when they are map keys (and all keys in the map are "string-able"). The other types are always cached.
I believe the rationale here is that we want to cache things that are likely to appear more than once. tags, keywords, and symbols generally carry some semantic or a reference to a specific thing, and are therefore likely to reappear. Strings as map keys are likely to reoccur if there is a collection of maps. Strings that are not map keys, who knows? Make sense?
Yeah, that makes sense. Thanks for clarifying.
I'd also like to vote for clarification. Again
tag, keyword and symbol values, and strings used as map keys are cached if they are longer than 3 characters.
is not clear. I only realized the behavior by trying it out. This is important when designing the API.
Well, this issue gives new meaning to "(probably not before next week)" in my first comment! I will pursue getting this addressed today!
I updated the Caching section of the README. Please let me know if anything is still unclear.
https://github.com/cognitect/transit-format#caching
next id=42
mean? It appears out of context.Thank you for this awesome piece of software.