UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Tby8+XUcbJYRlqY//Ct+Ywwv8TUuWs/2wIASp5kZ8M8=' 
WHERE 
  key_id = '311783c91d66c4b0fa27b116cbe525d4d4318300c70a54b641deccce7ea5361f' 
  AND (
    token = 'Tby8+XUcbJYRlqY//Ct+Ywwv8TUuWs/2wIASp5kZ8M8=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00024