Repository navigation
1.6.0
- The scheme of reconstructing the return value of the cache function, uses the secondary lock. Solve the lock contention problem when the function is called concurrently with different parameters.
- The return value of the method in the cache class supports setting the expiration time.
- Add a decorator named
count, supports caching the return value of a function by number of calls. - The decorator with cache expiration
expiresis renamed tottl. - The cache expiration time parameter can be passed in unit-time (such as "1h40m").
- Fix issue: When an exception occurs in the call to the cached object, subsequent successive calls always raise
KeyError: '__return__'. #2 - Fix issue: Concurrent calls when the return value of the function has not been cached or has expired may repeat the execution of the function. #4
- The
__getattribute__method is no longer silently overridden, and an exception is thrown directly if it exists. - Internal code adds type annotations, as well as a lot of optimization and refactoring.
- Refactor the internal method
Time2Secondto make it more concise and efficient. - Use
time.monotonic()to replacetime.time()for cache expiration checks. - Fix the potential errors that may occur in the class cache when running in performance mode.
- 重构缓存函数返回值的方案,现采用二级锁。解决以不同参数并发调用函数时的锁竞争问题。
- 缓存类中方法的返回值支持设置过期时间。
- 新增装饰器
count,支持按调用次数缓存函数的返回值。 - 带缓存有效期的装饰器
expires更名为ttl。 - 缓存过期时间的参数支持按单位时间(如 "1h40m")的方式传入。
- 修复问题:当被缓存的对象调用出现异常后,后续的连续调用始终引发
KeyError: '__return__'。#2 - 修复问题:当函数返回值还未被缓存或已过期时的并发调用可能重复执行函数。#4
- 不再静默覆盖
__getattribute__方法,如果它存在,将直接抛出异常。 - 内部代码添加类型注解,以及大量优化和重构。
- 重构内部方法
Time2Second使之更简洁和高效。 - 使用
time.monotonic()替换time.time()进行缓存过期检查。 - 修复在性能模式下运行时类缓存器可能发生的错误。
What's Changed
- 1.6.0 by @2018-11-27 in #10
Full Changelog: 1.5.4...1.6.0