
Research
Security News
The Landscape of Malicious Open Source Packages: 2025 Mid‑Year Threat Report
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
redis-tagged-cache
is a Python 3.7+ cache library backed with Redis with O(1) tags-based invalidation system.
Installation: pip install redis-tagged-cache
Usage:
from rtc import CacheMiss, RedisTaggedCache
cache = RedisTaggedCache(
namespace="foo",
host="localhost",
port=6379,
)
invalidation_tags = ["tag1", "tag2"] # tags are only strings of your choice
# Let's store something in the cache under the key "key1"
# (with a 60s lifetime)
cache.set("key1", "my value", tags=invalidation_tags, lifetime=60)
# it will output "my value" (cache hit!)
print(cache.get("key1", tags=invalidation_tags))
# Let's invalidate a tag (O(1) operation)
cache.invalidate("tag2")
# As the "key1" entry is tagged with "tag1" and "tag2"...
# ...the entry is invalidated (because we just invalidated "tag2")
# It will print "cache miss"
try:
cache.get("key1", tags=invalidation_tags)
except CacheMiss:
print("cache miss")
from rtc import RedisTaggedCache
cache = RedisTaggedCache(
namespace="foo",
host="localhost",
port=6379,
)
class A:
@cache.decorator(lifetime=60, tags=["tag1", "tag2"])
def slow_method(self, arg1: str, arg2: str = "foo"):
print("called")
return arg1 + arg2
if __name__ == "__main__":
a = A()
# It will output "called" and "foobar" (cache miss)
print(a.slow_method("foo", arg2="bar"))
# It will output "foobar" (cache hit)
print(a.slow_method("foo", arg2="bar"))
# It will output "called" and "foo2bar" (cache miss)
print(a.slow_method("foo2", arg2="bar"))
You will find the full API in this reference documentation.
All methods have a O(1) complexity regarding the number of keys. The invalidation is synchronous and very fast event if you invalidate millions of keys.
Note: complexity is O(n) regarding the number of tags.
The invalidation system does not really remove keys from redis. Invalidated entries are inaccessible (from the API) but they are not removed when the invalidation occurred. They are going to expire by themselves.
Be sure to configure your redis instance as a cache with capped memory (see maxmemory
configuration parameter) and maxmemory-policy allkeys-lru
settings about keys automatic eviction
As we support Python 3.7+ for the runtime, the dev environment requires Python 3.9+.
make lint
: for linting the codemake test
: for executing test(the venv will be automatically created)
FAQs
Unknown package
We found that redis-tagged-cache demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.