Propagate cache stats from ets operations and fix dialyzer issues#23
Propagate cache stats from ets operations and fix dialyzer issues#23matyasmarkovics wants to merge 6 commits intoalertlogic:masterfrom
Conversation
…time when applying it (more efficient), fix dialyzer issues
|
@kkuzmin @motobob and @raghavkarol Please review these changes and provide feedback where necessary. Much appreciated. |
raghavkarol
left a comment
There was a problem hiding this comment.
Looks OK when eyeballing, but since I don't maintain I can not say if the tests cover all the code touched affected here and am wary of the side effects.
I suggest that instead of merging this to master we leave this change on a branch, pin AE to use that branch and then after some time merge to master.
|
Let me see, maybe I can get test coverage. |
+1, even with test coverage I would not be completely confident merging this to master right away. |
|
|
|
@carlisom @rmpalomino please review and merge |
rmpalomino
left a comment
There was a problem hiding this comment.
It doesn't look like this introduces any breaking changes. I'm not a fan of the way the function type specs were changed, now there is a combination of foo(term(), term()) -> term() and foo(Arg1, Arg2) -> Result when Arg1 :: term()..., I would prefer it to be done the original way since you didn't change the other existing type specs.
| Owner = ets:info(get_table_name(Name), owner), | ||
| MatchPattern = #cache_entry{_='_'}, | ||
| %% make sure the table has not disappeared out from under us | ||
| case ets:info(TableName, type) of | ||
| undefined -> ok; | ||
| _ -> purge_cache( Name, TableName, Now ) | ||
| end. | ||
| [operate_cache(Name, fun tc_purge_cache/2, MatchPattern, evict, true) || is_pid(Owner)], |
There was a problem hiding this comment.
To make use of operate_cache/5.
The way of "type-spec"-ing you've listed first becomes unreadable very quickly and also it would raise the question of where to inject line-breaks. I challenge you to list at least 3 developers who agree on where to put line-breaks :), I think that problem has a NP complexity. This project is old enough to have no code-formatting tools enabled. So in order to preserve readability, my only option was to introduce type-args in the type-spec.
Honestly that would be a tall order. It would be similar to reformatting the whole code-base with erlfmt. Lots of changes to review in both cases. |
24f334f to
877cdfe
Compare
|
FYI: While I can see that the PR has been approved, I cannot do anything else. - I have no permission the merge this. :| |
|
@matyasmarkovics, has this been tested pinned in AE as @raghavkarol suggested? |
Functional
operate_cache/1where{increase_stat, StatName}would be used to bump-up the cache-statistic for the named operation.{increase_stat, StatName, Increment}is used for every cache-operation. The actualIncrementthen can be propagated from theetsoperations (or just defined as1for a singular change).Type-checking
erl_cache_servermodulecache_pt/3erl_cachemoduleNon-code