承接 mgleis/php-sqlite-key-value-store 相关项目开发

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

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

mgleis/php-sqlite-key-value-store

最新稳定版本:1.0.3

Composer 安装命令:

composer require mgleis/php-sqlite-key-value-store

包简介

A PHP library that implements a key/value store with SQLite as the persistence layer.

README 文档

README

A PHP library that implements a key/value store with SQLite as the persistence layer.

Use it for small projects / prototypes with at most hundreds or thousands of values.

The library now includes RPC server and client capabilities for remote access over HTTP.

Install

composer require mgleis/php-sqlite-key-value-store

Usage

Basic Local Usage

$kv = new KeyValueStore();

Set a Key

$kv->set('key', 'value');

Get a Value by Key

$value = $kv->get('key');

Check if a key exists

$exists = $kv->has('key');

Delete by Key

$kv->delete('key');

Search by Value

$arr = $kv->searchValueStartsWith('text');
$arr = $kv->searchValueContains('text');

Search by Key

$arr = $kv->searchKeyStartsWith('text');
$arr = $kv->searchKeyContains('text');

RPC Server and Client

Starting an RPC Server

You can expose your KeyValueStore via HTTP using the KeyValueStoreRpcServer:

use Mgleis\PhpSqliteKeyValueStore\KeyValueStoreRpcServer;

$server = new KeyValueStoreRpcServer('/rpc'); // Initialize server for route /rpc/*
$server->start();

This creates an HTTP server that accepts JSON-RPC requests at endpoints like:

  • POST /rpc/get - Get a value
  • POST /rpc/set - Set a key-value pair
  • POST /rpc/has - Check if key exists
  • POST /rpc/delete - Delete a key
  • POST /rpc/searchValueContains - Search values containing text
  • POST /rpc/searchValueStartsWith - Search values starting with text
  • POST /rpc/searchKeyContains - Search keys containing text
  • POST /rpc/searchKeyStartsWith - Search keys starting with text

Using the RPC Client

Connect to a remote KeyValueStore server using the client:

use Mgleis\PhpSqliteKeyValueStore\KeyValueStoreRpcClient;

$kv = new KeyValueStoreRpcClient('http://myserver.de:8080/rpc');

// Use exactly like the local KeyValueStore
$kv->set('key1', 'value1');
echo $kv->get('key1');
echo $kv->has('key1');
$kv->delete('key1');

// Search operations work the same way
$arr = $kv->searchValueStartsWith('text');
$arr = $kv->searchValueContains('text');
$arr = $kv->searchKeyStartsWith('text');
$arr = $kv->searchKeyContains('text');

The client implements the same interface as the local KeyValueStore, making it a drop-in replacement for remote access.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2024-12-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固