HN 표시: 지속형 개체의 무료 서버리스 Redis 클론(Upstash SDK에서 작동)

hackernews | | 💼 비즈니스
#cloudflare #redis #serverless #tip #upstash #무료 #durable objects
원문 출처: hackernews · Genesis Park에서 요약 및 분석

요약

개발자는 Cloudflare의 Durable Objects와 SQLite를 활용해 Upstash SDK와 호환되는 무료 서버리스 Redis 클론인 'meowdis'를 공개했습니다. 이 프로젝트는 Worker 무료 플랜에서 최대 5GB의 스토리지를 제공하며, Redis의 주요 문자열, 해시, 리스트, 만료 등의 다양한 명령어를 지원합니다. 또한 REST API나 SDK를 통해 Redis 명령을 보내면 내부적으로 SQLite 쿼리로 변환하여 트랜잭션 방식으로 처리하는 구조로 작동합니다.

본문

a free, serverless redis clone backed by cloudflare durable objects. drop-in replacement for upstash redis. - upstash compatible api (works w upstash sdks) - redis over http(s) / http compatible key-value store - pipelining support - free storage backed by cloudflare durable objects - low memory footprint <3 lambda go runtime | category | commands | |---|---| | strings | GET , SET , DEL , EXISTS , INCR , INCRBY , DECR , DECRBY , MGET , MSET | | expiry | EXPIRE , EXPIREAT , TTL , PTTL , PERSIST | | hashes | HGET , HSET , HDEL , HGETALL , HEXISTS , HKEYS , HVALS | | lists | LPUSH , RPUSH , LPOP , RPOP , LRANGE , LLEN | | sets | SADD , SREM , SMEMBERS , SISMEMBER , SCARD | | utility | PING , DBSIZE , FLUSHDB , KEYS | SET options: NX , XX , GET , EX , PX , EXAT , PXAT , KEEPTTL EXPIRE / EXPIREAT options: NX , XX , GT , LT LPOP / RPOP options: count - a compute layer exposes a POST endpoint - accepts upstash redis commands in the request body - translates the command into sqlite queries - forwards the queries to the storage layer, a durable object instance - durable object executes the queries against its sqlite database and returns the result - compute layer returns the result to the client set AUTH_TOKEN to a random secret string when prompted — generate one at jwtsecretkeygenerator.com tip: for lower latency, set a location hint in meowdis/src/index.ts before deploying to pin the durable object to a region close to your users:const stub = env.STORAGE.get(id, { locationHint: "apac" }); then initialise the database: curl https://meowdis.example.workers.dev \ -H "Authorization: Bearer your-token" \ -d '["INIT"]' verify it's working: curl https://meowdis.example.workers.dev \ -H "Authorization: Bearer your-token" \ -d '["PING"]' # {"result":"PONG"} python from upstash_redis import Redis redis = Redis(url="https://meowdis.example.workers.dev", token="your-token") redis.ping() # 'PONG' redis.set("name", "clairo") # 'OK' redis.get("name") # 'clairo' node import { Redis } from "@upstash/redis"; const redis = new Redis({ url: "https://meowdis.example.workers.dev", token: "your-token", }); await redis.ping(); // 'PONG' await redis.set("name", "clairo"); // 'OK' await redis.get("name"); // 'clairo' rest (see upstash rest api docs) curl https://meowdis.example.workers.dev \ -H "Authorization: Bearer your-token" \ -d '["PING"]' # {"result":"PONG"} curl https://meowdis.example.workers.dev \ -H "Authorization: Bearer your-token" \ -d '["SET", "name", "clairo"]' # {"result":"OK"} curl https://meowdis.example.workers.dev \ -H "Authorization: Bearer your-token" \ -d '["GET", "name"]' # {"result":"clairo"} 1. deploy the storage layer | variable | description | |---|---| STORAGE_SECRET | a random secret string -- generate one at jwtsecretkeygenerator.com | 2. deploy the compute layer option a — cloudflare worker (compute-node) | variable | description | |---|---| AUTH_TOKEN | a random secret string -- generate one at jwtsecretkeygenerator.com | option b — aws lambda (compute-go) | variable | description | |---|---| AUTH_TOKEN | a random secret string -- generate one at jwtsecretkeygenerator.com | STORAGE_ENDPOINT | url of your deployed durable object worker | STORAGE_TOKEN | the STORAGE_SECRET you set on the storage layer | 3. initialise the database curl https://your-compute-endpoint \ -H "Authorization: Bearer your-token" \ -d '["INIT"]' 4. verify it's working curl https://your-compute-endpoint \ -H "Authorization: Bearer your-token" \ -d '["PING"]' # {"result":"PONG"}

Genesis Park 편집팀이 AI를 활용하여 작성한 분석입니다. 원문은 출처 링크를 통해 확인할 수 있습니다.

공유

관련 저널 읽기

전체 보기 →