//Set adds a new value to the cache.
Set adds a new value to the cache.
// Set adds a new value to the cache .
func (c *CacheService) Set(ctx context.Context, req *cache.SetRequest) (*cache.SetResponse, error) {
	c.mutex.Lock()
	defer c.mutex.Unlock()
	_, ok := c.store[req.Key]
	if ok {
		log.Printf("key \"%s\"already exists\n", req.Key)
		return nil, status.Errorf(codes.AlreadyExists, "key \"%s\"already exists", req.Key)
	}
	log.Printf("setting key \"%s\"", req.Key)
	c.store[req.Key] = req.Value
	return &cache.SetResponse{Ok: true}, nil
}
func ( c * CacheService ) Set ( ctx context . Context , req * cache . SetRequest ) ( * cache . SetResponse , error ) { c . mutex . Lock ( ) defer c . mutex . Unlock ( ) _ , ok := c . store [ req . Key ] if ok { log . Printf ( " \" \" \n " , req . Key ) return nil , status . Errorf ( codes . AlreadyExists , " \" \" " , req . Key ) } log . Printf ( " \" \" " , req . Key ) c . store [ req . Key ] = req . Value return & cache . SetResponse { Ok : true } , nil }
Set adds a new value to the cache.
Set adds a new value to the cache .