A Distributed Caching Service with Rust ๐ฆ๐ฆ.
- โ Basic Cache
- โ LRU Cache
- โ Database Setup
- โ API Integration
- โ Docker Setup
- ๐ก Consistent Hashing
- ๐ก Distributed Cache - Dedicated cache cluster
Create a config
directory. And add default.toml
file with the following configuration.
Sample default.toml file is provided in the config
directory config/sample_default.toml. Also add a .env
file with the
configuration in config/.env.sample file.
- Clone the repository and navigate to the project directory.
git clone https://github.com/jiisanda/pandas-pouch.git
cd pandas-pouch
- Start the service using
docker-compose
.
docker-compose build
docker-compose up
You can use grpcurl
to interact with the service. Install grpcurl
using the installation guide in the grpcurl repository
Run the following command to interact with the service.
- Put operation
grpcurl -plaintext -proto proto/pandas_pouch.proto -d '{"key": "key2", "value": "value2"}' 0.0.0.0:50051 pandas_pouch.PandasPouchCacheService/Put
- Get Operation
grpcurl -plaintext -proto proto/pandas_pouch.proto -d '{"key": "key2"}' 0.0.0.0:50051 pandas_pouch.PandasPouchCacheService/Get
- PrintAll Operation
grpcurl -plaintext -proto proto/pandas_pouch.proto 0.0.0.0:50051 pandas_pouch.PandasPouchCacheService/PrintAll
To use pandas-pouch as a crate, add the following to your Cargo.toml
file.
[dependencies]
pandas-pouch = { git = "https://github.com/jiisanda/pandas-pouch.git" }
Using it in code:
use pandas_pouch::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut client = Client::new("http://localhost:50051").await?;
// put a value
client.put("key1".to_string(), "value1".to_string()).await?;
// get a value
let value = client.get("key1".to_string()).await?;
println!("Value: {:?}", value);
Ok(())
}
This project is licensed under the MIT License.