mirror of
https://github.com/langgenius/dify-docs.git
synced 2026-03-27 13:28:32 +07:00
74 lines
2.5 KiB
Plaintext
74 lines
2.5 KiB
Plaintext
---
|
|
dimensions:
|
|
type:
|
|
primary: reference
|
|
detail: core
|
|
level: beginner
|
|
standard_title: Persistent Storage KV
|
|
language: ja
|
|
title: 永続ストレージ
|
|
description: このドキュメントでは、Difyプラグインの永続ストレージ機能について説明し、プラグインでKVデータベースを使用してデータを保存、取得、削除する方法を詳しく説明します。この機能により、プラグインは同じワークスペース内でデータを永続的に保存でき、セッションをまたいだデータ保存のニーズに対応できます。
|
|
---
|
|
|
|
プラグイン内のツールおよびエンドポイントを個別に見てみると、ほとんどの場合、単一のインタラクションしか完了できず、リクエスト後にデータを返してタスクが終了することがわかります。
|
|
|
|
永続的な記憶の実装など、長期間保存する必要があるデータが存在する場合、プラグインには永続ストレージ機能が求められます。**永続ストレージメカニズムにより、プラグインは同一ワークスペース内でデータを永続的に保存することが可能になります。**現在はKVデータベースを提供することでストレージのニーズに対応していますが、将来的には実際の使用状況に基づき、より柔軟で強力なストレージインターフェースを提供する可能性があります。
|
|
|
|
### キーの保存
|
|
|
|
#### **エントリポイント**
|
|
|
|
```python
|
|
self.session.storage
|
|
```
|
|
|
|
#### **インターフェース**
|
|
|
|
```python
|
|
def set(self, key: str, val: bytes) -> None:
|
|
pass
|
|
```
|
|
|
|
渡されるのはbytesであることに注意してください。そのため、実際にはその中にファイルを保存することができます。
|
|
|
|
### キーの取得
|
|
|
|
#### **エントリポイント**
|
|
|
|
```python
|
|
self.session.storage
|
|
```
|
|
|
|
#### **インターフェース**
|
|
|
|
```python
|
|
def get(self, key: str) -> bytes:
|
|
pass
|
|
```
|
|
|
|
### キーの削除
|
|
|
|
#### **エントリポイント**
|
|
|
|
```python
|
|
self.session.storage
|
|
```
|
|
|
|
#### **インターフェース**
|
|
|
|
```python
|
|
def delete(self, key: str) -> None:
|
|
pass
|
|
```
|
|
|
|
{/*
|
|
Contributing Section
|
|
DO NOT edit this section!
|
|
It will be automatically generated by the script.
|
|
*/}
|
|
|
|
---
|
|
|
|
[このページを編集する](https://github.com/langgenius/dify-docs/edit/main/plugin-dev-ja/0411-persistent-storage-kv.mdx) | [問題を報告する](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml)
|
|
|