Files
services/cache/proto/cache.proto
Asim Aslam 7130cf2ae0 revert
2022-02-18 20:35:11 +00:00

95 lines
2.0 KiB
Protocol Buffer

syntax = "proto3";
package cache;
option go_package = "./proto;cache";
service Cache {
rpc Get(GetRequest) returns (GetResponse) {}
rpc Set(SetRequest) returns (SetResponse) {}
rpc Delete(DeleteRequest) returns (DeleteResponse) {}
rpc Increment(IncrementRequest) returns (IncrementResponse) {}
rpc Decrement(DecrementRequest) returns (DecrementResponse) {}
rpc ListKeys(ListKeysRequest) returns (ListKeysResponse) {}
}
// Get an item from the cache by key. If key is not found, an empty response is returned.
message GetRequest {
// The key to retrieve
string key = 1;
}
message GetResponse {
// The key
string key = 1;
// The value
string value = 2;
// Time to live in seconds
int64 ttl = 3;
}
// Set an item in the cache. Overwrites any existing value already set.
message SetRequest {
// The key to update
string key = 1;
// The value to set
string value = 2;
// Time to live in seconds
int64 ttl = 3;
}
message SetResponse {
// Returns "ok" if successful
string status = 1;
}
// Delete a value from the cache. If key not found a success response is returned.
message DeleteRequest {
// The key to delete
string key = 1;
}
message DeleteResponse {
// Returns "ok" if successful
string status = 1;
}
// Increment a value (if it's a number). If key not found it is equivalent to set.
message IncrementRequest {
// The key to increment
string key = 1;
// The amount to increment the value by
int64 value = 2;
}
message IncrementResponse {
// The key incremented
string key = 1;
// The new value
int64 value = 2;
}
// Decrement a value (if it's a number). If key not found it is equivalent to set.
message DecrementRequest {
// The key to decrement
string key = 1;
// The amount to decrement the value by
int64 value = 2;
}
message DecrementResponse {
// The key decremented
string key = 1;
// The new value
int64 value = 2;
}
// List all the available keys
message ListKeysRequest {
}
message ListKeysResponse {
repeated string keys = 1;
}