
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
compression-cache
Advanced tools
COMPRESSION-CACHE β ΡΡΠΎ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠ°, ΠΏΡΠ΅Π΄Π½Π°Π·Π½Π°ΡΠ΅Π½Π½Π°Ρ Π΄Π»Ρ ΡΡΡΠ΅ΠΊΡΠΈΠ²Π½ΠΎΠ³ΠΎ ΠΊΡΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ ΡΠΆΠ°ΡΡΡ Π΄Π°Π½Π½ΡΡ . ΠΠ½Π° ΠΏΡΠ΅Π΄ΠΎΡΡΠ°Π²Π»ΡΠ΅Ρ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΡ Π΄Π»Ρ Ρ ΡΠ°Π½Π΅Π½ΠΈΡ ΠΈ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΡ ΡΠΆΠ°ΡΡΠΌΠΈ Π΄Π°Π½Π½ΡΠΌΠΈ Π² ΠΏΠ°ΠΌΡΡΠΈ ΠΈΠ»ΠΈ Π½Π° Π΄ΠΈΡΠΊΠ΅, ΠΏΠΎΠ·Π²ΠΎΠ»ΡΡ ΡΡΠΊΠΎΡΠΈΡΡ ΠΎΠ±ΡΠ°Π±ΠΎΡΠΊΡ Π΄Π°Π½Π½ΡΡ ΠΏΡΡΠ΅ΠΌ ΠΏΠΎΠ²ΡΠΎΡΠ½ΠΎΠ³ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΡ ΡΠΆΠ΅ ΡΠΆΠ°ΡΡΡ ΠΎΠ±ΡΠ΅ΠΊΡΠΎΠ². ΠΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠ° ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ ΠΏΠΎΠ»Π΅Π·Π½Π° Π² ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡΡ , Π³Π΄Π΅ ΡΡΠ΅Π±ΡΠ΅ΡΡΡ ΡΠ°ΡΡΠΎΠ΅ ΡΡΠ΅Π½ΠΈΠ΅ ΠΈ Π·Π°ΠΏΠΈΡΡ Π±ΠΎΠ»ΡΡΠΈΡ ΠΎΠ±ΡΠ΅ΠΌΠΎΠ² Π΄Π°Π½Π½ΡΡ , ΡΠ°ΠΊΠΈΡ ΠΊΠ°ΠΊ Π±Π°Π·Ρ Π΄Π°Π½Π½ΡΡ , ΡΠΈΡΡΠ΅ΠΌΡ Ρ ΡΠ°Π½Π΅Π½ΠΈΡ ΠΈ ΠΊΡΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ, Π° ΡΠ°ΠΊΠΆΠ΅ Π² ΠΎΠ±Π»Π°ΡΡΡΡ Ρ ΠΎΠ³ΡΠ°Π½ΠΈΡΠ΅Π½ΠΈΡΠΌΠΈ ΠΏΠΎ ΠΏΡΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡΠ΅Π»ΡΠ½ΠΎΡΡΠΈ, Π½Π°ΠΏΡΠΈΠΌΠ΅Ρ, Π² ΠΌΠΎΠ±ΠΈΠ»ΡΠ½ΡΡ ΠΈΠ»ΠΈ Π²ΡΡΡΠΎΠ΅Π½Π½ΡΡ ΡΠΈΡΡΠ΅ΠΌΠ°Ρ .
pip install compression-cache
ΠΡΠΈΠΌΠ΅Ρ Π°ΡΠΈΠ½Ρ ΡΠΎΠ½Π½ΠΎΠ³ΠΎ ΠΊΡΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ ΠΌΠΎΠΆΠ½ΠΎ Π½Π°ΠΉΡΠΈ Π² ΡΠ°ΠΉΠ»Π΅
import asyncio, faker, random
from typing import Dict, List, Union
from compression_cache import CacheTTL
async def get_accounts(count_account: int) -> List[Dict[str, Union[str, int]]]:
print(f"Get new list accounts count_account: {count_account}")
fake = faker.Faker()
accounts: List[Dict[str, Union[str, int]]] = []
for _ in range(count_account):
account = {
"id": random.randint(1000, 9999),
"name": fake.user_name(),
"first_name": fake.first_name(),
"last_name": fake.last_name(),
}
accounts.append(account) # type: ignore
return accounts
@CacheTTL(ttl=60 * 5, key_args=["count_account"], compressor_level=3)
async def async_function(count_account: int) -> List[Dict[str, Union[str, int]]]:
return await get_accounts(count_account=count_account)
async def main():
for count_account in [10, 20, 10, 20]:
print(f"count_account: {count_account}")
await async_function(count_account=count_account)
asyncio.run(main())
ΠΡΠΈΠΌΠ΅Ρ ΡΠΈΠ½Ρ ΡΠΎΠ½Π½ΠΎΠ³ΠΎ ΠΊΡΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ ΠΌΠΎΠΆΠ½ΠΎ Π½Π°ΠΉΡΠΈ Π² ΡΠ°ΠΉΠ»Π΅
import faker, random
from typing import Dict, List, Union
from compression_cache import CacheTTL
def get_accounts(count_account: int) -> List[Dict[str, Union[str, int]]]:
print(f"Get new list accounts count_account: {count_account}")
fake = faker.Faker()
accounts: List[Dict[str, Union[str, int]]] = []
for _ in range(count_account):
account = {
"id": random.randint(1000, 9999),
"name": fake.user_name(),
"first_name": fake.first_name(),
"last_name": fake.last_name(),
}
accounts.append(account) # type: ignore
return accounts
@CacheTTL(ttl=60 * 5, key_args=["count_account"], compressor_level=3)
def async_function(count_account: int) -> List[Dict[str, Union[str, int]]]:
return get_accounts(count_account=count_account)
def main():
for count_account in [10, 20, 10, 20]:
print(f"count_account: {count_account}")
async_function(count_account=count_account)
main()
MIT License
FAQs
Python function caching with compression
We found that compression-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.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rustβs crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.