infinityloop-dev/graphpinator-persisted-queries
Composer 安装命令:
composer require infinityloop-dev/graphpinator-persisted-queries
包简介
Module to persist validated query in cache and improve performace of repeating queries.
README 文档
README
⚡🌐⚡ Module to persist validated query in cache and improve performace of repeating queries.
Introduction
This Module allows GraPHPinator to cache queries on the server to reduce server load. This module aims to reduce GraphQL overhead in parsing and validation by caching and reusing known requests.
Please note that this module does not affect the speed of your resolver functions.
Installation
Install package using composer
composer require infinityloop-dev/graphpinator-persisted-queries
How to use
- Implement
\Psr\SimpleCache\CacheInterface
You need implementation of \Psr\SimpleCache\CacheInterface where the serialized version of request is stored for later reuse.
- Register
PersistedQueriesModuleas GraPHPinator module:
$persistModule = new \Graphpinator\PersistedQueriesModule\PersistedQueriesModule($schema, $cacheImpl); $graphpinator = new \Graphpinator\Graphpinator( $schema, $catchExceptions, new \Graphpinator\Module\ModuleSet([$persistModule, /* possibly other modules */]), $logger, );
- You are all set, queries are automatically cached in specified storage.
Performance improvements
Simple benchmark (code in bench directory) shows approximatelly 80% reduction of GraphQL overhead.
Benchmark runs the same query 10k times, with 5 warmup queries before. Cache in use is a simple implementation using Redis on localhost, connection is done using php-redis extension. Opcache was disabled.
| CPU model | Time WITHOUT module | Time WITH module |
|---|---|---|
| Ryzen 5900X | ~12.44 s | ~2.16 s |
| Ryzen 5600X (using VMware) | ~24.83 s | ~4.69 s |
| Ryzen 5 3600 | ~14.97 s | ~2.77 s |
infinityloop-dev/graphpinator-persisted-queries 适用场景与选型建议
infinityloop-dev/graphpinator-persisted-queries 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21.45k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2021 年 06 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 infinityloop-dev/graphpinator-persisted-queries 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 infinityloop-dev/graphpinator-persisted-queries 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 21.45k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 3
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2021-06-29