syntax = "proto3";

package cache;

option go_package = "./proto;cache";

// Cache offers a cache as a service functionality.
service Cache {
    // Get receives a value and its time to live by key from the cache.
    rpc Get(GetRequest) returns (GetResponse) {}
    // Put stores a value and its time to live in the cache.
    rpc Put(PutRequest) returns (PutResponse) {}
    // Delete removes a key from the cache.
    rpc Delete(DeleteRequest) returns (DeleteResponse) {}
}

message GetRequest {
    // The key to fetch from the cache.
    string key = 1;
}

message GetResponse {
    // The value retrieved from the cache.
    string value = 1;
    // The value's expiration datetime.
    string expiration = 2;
}

message PutRequest {
    // The key to store in the cache.
    string key = 1;
    // The value to store in the cache.
    string value = 2;
    // The value's time to live. Parsed using time.ParseDuration. 0 means
    // it doesn't expire.
    string duration = 3;
}

message PutResponse {}

message DeleteRequest {
    // The key to remove from the cache.
    string key = 1;
}

message DeleteResponse {}
