
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@braken/cache
Advanced tools
Braken 框架的缓存模块,提供多级缓存支持。
pnpm add @braken/cache
import { Application } from '@braken/application';
import CacheServer from '@braken/cache';
import FileCache from '@braken/cache-file';
import IORedisCache from '@braken/cache-ioredis';
// 创建缓存实例
const fileCache = new FileCache();
const redisCache = new IORedisCache();
// 配置缓存服务器
CacheServer.set([fileCache, redisCache]);
// 使用缓存
@Application.Injectable
class MyService {
@Application.Inject(CacheServer)
private readonly cache: CacheServer;
async getUser(id: string) {
// 尝试从缓存读取
const cached = await this.cache.read(`user:${id}`);
if (cached) {
return cached;
}
// 从数据库读取
const user = await this.fetchUserFromDB(id);
// 写入缓存
await this.cache.write(`user:${id}`, user, Date.now() + 3600000);
return user;
}
async updateUser(id: string, data: any) {
// 更新数据库
await this.updateUserInDB(id, data);
// 更新缓存
await this.cache.rewrite(`user:${id}`, data, Date.now() + 3600000, 2);
}
}
主要的缓存服务器类,提供以下功能:
设置缓存配置:
static set(props: CacheProps[])
写入缓存:
async write(key: string, value: any, expire?: number)
读取缓存:
async read(key: string)
检查缓存是否存在:
async has(key: string)
删除缓存:
async delete(key: string)
获取过期时间:
async expire(key: string)
查找缓存:
async find(key: string)
重写缓存:
async rewrite(key: string, value: any, expire: number, i: number)
获取指定索引的缓存:
get<T = any>(index: number): CacheProps<T>
@Application.Injectable
class MyService {
@Application.Inject(CacheServer)
private readonly cache: CacheServer;
}
MIT
FAQs
somethings
The npm package @braken/cache receives a total of 0 weekly downloads. As such, @braken/cache popularity was classified as not popular.
We found that @braken/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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.