-
Notifications
You must be signed in to change notification settings - Fork 2
feat(DEVC-1286): Revamp redis usage #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(DEVC-1286): Revamp redis usage #111
Conversation
- upgrade redis version for test server - bump bunch of related third party dependencies: - fakeredis[lua] -> removed prefix LUA - redis == 6.2.0 latest supported with Python3.9+ - types-redis~=4.6.0 - removed: - all LUA bindings from RedisRepository - use_lua_52 - vacuum(...) and dependant codes - InternalCacheSdkProtocol - InternalRedisSdk - FakeInternalCacheSdk
| returns: stored data | ||
| def check_redis_server_version(self) -> None: | ||
| # Require Redis 7.4+ for per-field TTL commands | ||
| redis_version_str = self.client.info(section="server")["redis_version"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just curious, does this self.client.info() actually queries redis server or is it generated once after connection is established? Because if it queries stuff than you should probably do this once in init, store it in some attribute and then use attribute here
src/corva/service/cache_sdk.py
Outdated
| redis_client = redis.Redis.from_url(url=redis_dsn, decode_responses=True) | ||
|
|
||
| migrator = HashMigrator(hash_name, redis_client) | ||
| migrator.run() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so you want to run this on every execution even if app will not touch cache at all? It's probably a micro-optimization but a lot of apps don't actually use cache at all, so maybe let's do it in "lazy" way - trigger this .run() when app tries to read/write/delete something for the first time? Add some flag attribute to this UserRedisSdk class, set it to False by default. If user calls one of the methods (get, set, ...) you can check if attribute is False, if it is - call that .run() method and set flag to true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds great, like it, will add this soon, thanks! 🚀
…is==7.4.0; few updates at UserRedisSdk
ea17c1a
into
feature/DEVC-1282-migrate-to-pydantic-v2
* feat: remove redis ping * feat(DEVC-265): add py-typed file & update pyproject.toml accordingly * feat(DEVC-265): ensure that lint passed; bump mypy version from mypy==0.950 -> mypy>=1.10,<2 * feat(DEVC-265): move mypy CLI args into single place - pyproject.toml file * feat(DEVC-265): remove exclude block at mypy settings for skipping some docs/modules tutorials * feat(DEVC-265): optimise mypy config * feat(DEVC-1282): migrate SDK code to pydantic V2 * feat(DEVC-1282): migrate tests to pydantic v2 as well; add some fixes * feat(DEVC-1282): improve type annotations; refactor RerunTimeRange class validators at to simplify * feat(DEVC-1282): fix annotations for `model_validator` with mode="before" * feat(DEVC-1282): set new minor version * feat(DEVC-1286): Revamp redis usage (#111) - upgrade redis version for test server - bump bunch of related third party dependencies: - fakeredis[lua] -> removed prefix LUA - redis == 6.2.0 latest supported with Python3.9+ - types-redis~=4.6.0 - removed: - all LUA bindings from RedisRepository - use_lua_52 - vacuum(...) and dependant codes - InternalCacheSdkProtocol - InternalRedisSdk - FakeInternalCacheSdk - DeprecatedRedisAdapter - Add migration logic
Changes
HashMigratorto encap hash redis keys migration in BC way (by creating new key with separate prefix to not break old keys if they will be needed while reverting)FakeRedisclass since by default it doesn't support.info()methodfakeredis[lua]-> removed prefix LUAredis == 6.2.0latest supported with Python3.9+types-redis~=4.6.0RedisRepositoryuse_lua_52vacuum(...)and dependant codesInternalCacheSdkProtocolInternalRedisSdkFakeInternalCacheSdkDeprecatedRedisAdapterDEVC-1286