Skip to content

Latest commit

 

History

History
56 lines (35 loc) · 1.48 KB

memory.md

File metadata and controls

56 lines (35 loc) · 1.48 KB

In-Memory Extension Overview

In-Memory Filesystem extension is an in-memory storage extension designed for storing and retrieving data from memory.


Note: This extension is used for development and testing purposes. The use of this extension will result in data loss if it is not pulled from memory.


WARNING: PLEASE BE SURE TO HAVE ENOUGH AVAILABLE MEMORY BEFORE STORING ANY LARGE AMOUNTS OF DATA IN MEMORY, OTHERWISE THERE IS A CHANGE OF SYSTEM INSTABILITY OR THE APPLICATION CRASHES DUE TO AN OUT-OF-MEMORY ERROR

Importing extension into cargo project

In your cargo project add the following

[dependencies]
warp = { git = "https://github.com/Satellite-im/Warp" }
warp-extensions = { git = "https://github.com/Satellite-im/Warp", features = ["fs_memory"] }

Starting Extension

	use warp::constellation::Constellation;
	use warp_extensions::fs_memory::MemorySystem;

	let mut system = MemorySystem::new();

Testing InMemory Extension

Upload Content

	use warp::constellation::Constellation;
	use warp_extensions::fs_memory::MemorySystem;
	
	let mut system = MemorySystem::new();

	system.put_buffer("new_file", &b"This is content to the file".to_vec()).await.unwrap();

Download Content

	use warp::constellation::Constellation;
	use warp_extensions::fs_memory::MemorySystem;
	
	let mut system = MemorySystem::new();

	let buffer = system.get_buffer("new_file").await.unwrap();

	println!("{}", String::from_utf8_lossy(&buffer));