承接 ferdiunal/laravel-cache-couchdb 相关项目开发

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

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

ferdiunal/laravel-cache-couchdb

最新稳定版本:v0.1.1

Composer 安装命令:

composer require ferdiunal/laravel-cache-couchdb

包简介

This package provides a cache store implementation for Laravel that uses a CouchDB database to store cached items. It supports both the default and tagged cache functionality of Laravel.

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package provides a cache store implementation for Laravel that uses a CouchDB database to store cached items. It supports both the default and tagged cache functionality of Laravel.

Requirements

This package requires the following:

  • PHP >= 8.2
  • Laravel >= 9.0
  • A CouchDB instance

Installation

You can install this package via Composer. Run the following command:

composer require ferdiunal/laravel-couchdb-cache

Configuration

To use the CouchDB cache driver, you will need to add it to the config/cache.php file as follows:

'default' => env('CACHE_DRIVER', 'file'),
...
'couchdb' => [
    'driver' => 'couchdb',
    'host' => env('COUCHDB_HOST', 'localhost'),
    'port' => env('COUCHDB_PORT', 5984),
    'user' => env('COUCHDB_USERNAME', null),
    'password' => env('COUCHDB_PASSWORD', null),
    'ip' => env('COUCHDB_IP', null),
    'ssl' => env('COUCHDB_SSL', false),
    'path' => env('COUCHDB_PATH', null),
    'logging' => env('COUCHDB_LOGGING', false),
    'timeout' => env('COUCHDB_TIMEOUT', 0.01),
    'dbname' => env('COUCHDB_DATABASE', 'your_database_name'),
    'prefix' => env('CACHE_PREFIX', 'your_cache_prefix'),
];

You can then set the CACHE_DRIVER environment variable to 'couchdb' to use the CouchDB cache driver.

Usage

After the configuration is set up, you can use the CouchDB cache driver in your Laravel application as you would any other cache driver. Here are a few examples:

// Store an item in the cache for 10 minutes
Cache::put('key', 'value', 10);

// Retrieve an item from the cache by key
$value = Cache::get('key');

// Retrieve multiple items from the cache by keys
$values = Cache::many(['key1', 'key2']);

// Increment the value of an item in the cache
Cache::increment('key');

// Decrement the value of an item in the cache
Cache::decrement('key');

// Remove an item from the cache
Cache::forget('key');

// Remove all items from the cache
Cache::flush();

Tagged Cache

The CouchDB cache driver also supports the tagged cache functionality of Laravel. Here are a few examples:

// Store an item in the cache with a tag
Cache::tags(['tag1', 'tag2'])->put('key', 'value', 10);

// Retrieve all items with a tag
Cache::tags('tag1')->get('key');

// Remove all items with a tag
Cache::tags('tag1')->flush();

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-02