Reputation: 14868
Are there any default limits on the goon local memory cache, so it won't fill up the memory and cause some sort of our of memory exception? I can see there's a public FlushLocalCache method but I don't see it being used anywhere within the library. If the lib doesn't auto take care of clearing out the local memory cache, what would be a good schema to use to ensure you don't over use your memory size?
Upvotes: 2
Views: 208
Reputation: 73236
The documentation of goon says the local cache is per-request, meaning that it will only accumulate data for the duration of the current request.
Actually the local cache is part of a Goon object, which is supposed to be created from an appengine context, created from the request itself (see NewGoon and FromContext functions). The corresponding cached data can be garbage collected once the request has been processed.
So nothing actually limits the memory that can be accumulated in the local cache, but in practice it is harmless, because a single request is not supposed to deal with a massive amount of data. The pathological case of a request looping while adding many records in the cache is possible though.
One of the drawback of this approach is it tends to generate useless garbage if the cached data are not used. But it may simplify some code. For instance, the roundtrips generated by repetitive validations based on referential data can be optimized away without additional complexity.
Note that if the local cache spanned over several requests, it would be difficult to define a proper cache invalidation strategy while still maintaining control on the data consistency.
Upvotes: 1