承接 cachly-dev/sdk 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cachly-dev/sdk

Composer 安装命令:

composer require cachly-dev/sdk

包简介

Official PHP SDK for cachly.dev – Managed Valkey/Redis cache with semantic AI caching

README 文档

README

Official PHP SDK for cachly.dev – Managed Valkey/Redis cache.

GDPR-compliant · German servers · Live in 30 seconds

Installation

composer require cachly/sdk

Requires PHP ≥ 8.1 and predis/predis ^2.2.

Quick Start

use Cachly\CachlyClient;

$cache = new CachlyClient('redis://:your-password@my-instance.cachly.dev:6379');

// Set a value with TTL
$cache->set('user:42', ['name' => 'Alice', 'plan' => 'pro'], ttl: 300);

// Get a value
$user = $cache->get('user:42'); // ['name' => 'Alice', 'plan' => 'pro']

// Check existence
if ($cache->exists('user:42')) { ... }

// TTL refresh
$cache->expire('user:42', 600);

// Atomic counter
$count = $cache->incr('page:views');

// Delete
$cache->del('user:42');

Get-or-Set Pattern

$data = $cache->getOrSet(
    key: 'expensive:report',
    fn:  fn() => $db->runExpensiveReport(),
    ttl: 60,
);

Semantic AI Cache (Speed / Business tiers)

Cache LLM responses by meaning, not just exact key. Cut OpenAI costs by 60%.

use Cachly\CachlyClient;

$cache  = new CachlyClient(getenv('CACHLY_URL'));
$openai = new OpenAI\Client(getenv('OPENAI_API_KEY'));

$embedFn = fn(string $text) => $openai
    ->embeddings()
    ->create(['model' => 'text-embedding-3-small', 'input' => $text])
    ->data[0]->embedding;

$result = $cache->semantic()->getOrSet(
    prompt:              $userQuestion,
    fn:                  fn() => $openai->chat($userQuestion),
    embedFn:             $embedFn,
    similarityThreshold: 0.90,
    ttl:                 3600,
);

echo $result->hit
    ? "⚡ Cache hit (similarity={$result->similarity})"
    : "🔄 Fresh from LLM";
echo $result->value;

Laravel Integration

// config/cachly.php
return ['url' => env('CACHLY_URL')];

// AppServiceProvider
$this->app->singleton(CachlyClient::class, fn() => new CachlyClient(config('cachly.url')));

// In a controller / service
public function __construct(private CachlyClient $cache) {}

API Reference

Method Description
get(string $key) Get a value (null if not found)
set(string $key, mixed $value, ?int $ttl) Set a value
del(string ...$keys): int Delete keys, returns count
exists(string $key): bool Check existence
expire(string $key, int $seconds) Update TTL
incr(string $key): int Atomic increment
getOrSet(string $key, callable $fn, ?int $ttl) Get-or-set pattern
semantic(): SemanticCache Access semantic cache helper
raw(): PredisClient Direct Predis access

Batch API — Multiple Ops in One Round-Trip

Bundle GET/SET/DEL/EXISTS/TTL operations into one HTTP request or Predis pipeline.

use Cachly\CachlyClient;
use Cachly\BatchOp;

$cache = new CachlyClient(
    url: $_ENV['CACHLY_URL'],
    batchUrl: $_ENV['CACHLY_BATCH_URL'] ?? null, // optional
);

$results = $cache->batch([
    BatchOp::get('user:1'),
    BatchOp::get('config:app'),
    BatchOp::set('visits', '42', ttl: 86400),
    BatchOp::exists('session:xyz'),
    BatchOp::ttl('token:abc'),
]);

$user  = $results[0]->value;       // string|null
$ok    = $results[2]->ok;          // bool
$found = $results[3]->exists;      // bool
$secs  = $results[4]->ttlSeconds;  // int (-1 = no TTL, -2 = key missing)

Environment Variables

CACHLY_URL=redis://:your-password@my-app.cachly.dev:30101
CACHLY_BATCH_URL=https://api.cachly.dev/v1/cache/YOUR_TOKEN   # optional
# Speed / Business tier – Semantic AI Cache:
CACHLY_VECTOR_URL=https://api.cachly.dev/v1/sem/your-vector-token

Find both values in your cachly.dev dashboard.

AI Dev Brain — Persistent Memory for Your Coding Assistant

cachly ships a 30-tool MCP server that gives Claude Code, Cursor, GitHub Copilot, and Windsurf a persistent memory across sessions.

npx @cachly-dev/init

session_start(instance_id, focus) returns a full briefing in one call: last session summary, relevant lessons, open failures, brain health.

→ Full docs: cachly.dev/docs/ai-memory

Links

MIT © cachly.dev

cachly-dev/sdk 适用场景与选型建议

cachly-dev/sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 04 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「redis」 「cache」 「eu」 「dsgvo」 「llm」 「valkey」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 cachly-dev/sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 cachly-dev/sdk 我们能提供哪些服务?
定制开发 / 二次开发

基于 cachly-dev/sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 35
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-16