Skip to content

Commit

Permalink
fix local cache set and release 0.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Yiling-J committed Feb 3, 2023
1 parent 70bbffd commit 5b219cd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Changelog
All notable changes to this project will be documented in this file.

## [0.2.2]
### Fixed
- Fix local cache set existing key, policy should not update

### Changed
- Bump Cacheme-utils version

## [0.2.1]
### Added
- Remove expired nodes automatically
Expand Down
3 changes: 3 additions & 0 deletions cacheme/storages/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,16 @@ async def set_by_key(
value: Any,
ttl: Optional[timedelta],
):
exist = key in self.cache
expire = None
if ttl is not None:
expire = datetime.now(timezone.utc) + ttl
self.cache[key] = CachedValue(
data=value, updated_at=datetime.now(timezone.utc), expire=expire
)
self.cache.move_to_end(key)
if exist:
return
evicated = self.policy.set(key)
if evicated is not None:
self.cache.pop(evicated, None)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cacheme"
version = "0.2.1"
version = "0.2.2"
description = "async caching framework"
authors = ["Yiling-J <njjyl723@gmail.com>"]
readme = "README.md"
Expand Down

0 comments on commit 5b219cd

Please sign in to comment.