
Security News
The Nightmare Before Deployment
Season’s greetings from Socket, and here’s to a calm end of year: clean dependencies, boring pipelines, no surprises.
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
Season’s greetings from Socket, and here’s to a calm end of year: clean dependencies, boring pipelines, no surprises.

Research
/Security News
Impostor NuGet package Tracer.Fody.NLog typosquats Tracer.Fody and its author, using homoglyph tricks, and exfiltrates Stratis wallet JSON/passwords to a Russian IP address.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.