# @markdown Please specify an endpoint associated with the instance and a key prefix for demo purpose.ENDPOINT = "redis://127.0.0.1:6379" # @param {type:"string"}KEY_PREFIX = "doc:" # @param {type:"string"}
# # Automatically restart kernel after installs so that your environment can access the new packages# import IPython# app = IPython.Application.instance()# app.kernel.do_shutdown(True)
# @markdown Please fill in the value below with your Google Cloud project ID and then run the cell.PROJECT_ID = "my-project-id" # @param {type:"string"}# Set the project id!gcloud config set project {PROJECT_ID}
使用 MemorystoreDocumentSaver.delete() 删除 Memorystore for Redis 实例中所有具有指定前缀的键。您也可以指定键的后缀。
docs = loader.load()print("Documents before delete:", docs)saver.delete(ids=[0])print("Documents after delete:", loader.load())saver.delete()print("Documents after delete all:", loader.load())