You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,10 +8,10 @@ Basing on https://learn.microsoft.com/en-us/aspnet/core/performance/caching/dist
8
8
9
9
The Distributed MySQL Server Cache implementation (**AddDistributedMySqlCache**) allows the distributed cache to use a MySQL Server database as its backing store. To create a MySQL Server cached item table in a MySQL Server instance, you can use the `dotnet-mysql-cache` tool. The tool creates a table with the name and schema that you specify.
10
10
11
-
Create a table in MySQL Server by running the `dotnet mysql-cache create` command. Provide the MySQL Server connection string, instance (for example `server=192.169.0.1`), database (for example, `databaseName`), and table name (for example, `NewTableName`):
11
+
Create a table in MySQL Server by running the `dotnet mysql-cache create` command. Provide the MySQL Server connection string, instance (for example `server=192.169.0.1`), table name (for example, `NewTableName`) and optional database (for example, `MyDatabaseName`):
12
12
13
13
```dotnetcli
14
-
dotnet mysql-cache create "server=192.169.0.1;user id=userName;password=P4ssword123!;port=3306;database=databaseName;Allow User Variables=True" databaseName "NewTableName"
14
+
dotnet mysql-cache create "server=192.169.0.1;user id=userName;password=P4ssword123!;port=3306;database=MyDatabaseName;Allow User Variables=True" "NewTableName" --databaseName "MyDatabaseName"
15
15
```
16
16
17
17
A message is logged to indicate that the tool was successful:
@@ -33,8 +33,8 @@ The example snippet how to implement MySql Server cache in `Program.cs`:
Copy file name to clipboardExpand all lines: src/Pomelo.Extensions.Caching.MySqlConfig.Tools/Program.cs
+9-15Lines changed: 9 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -63,21 +63,21 @@ public int Run(string[] args)
63
63
64
64
cliApp.Command("create", command =>
65
65
{
66
-
command.Error=Error;//internal command Out/Erro are not yet changed, possible shortcomming
66
+
command.Error=Error;//internal command Out/Error are not yet changed, possible shortcoming
67
67
command.Out=Out;
68
68
69
69
command.Description=description;
70
70
varconnectionStringArg=command.Argument(
71
71
"[connectionString]",
72
72
"The connection string to connect to the database.");
73
-
vardatabaseNameArg=command.Argument("[databaseName]","Name of the database.");
73
+
//var databaseNameArg = command.Argument("[databaseName]", "Name of the database.");
74
+
vardatabaseNameOpt=command.Option("-d|--databaseName","Name of the database. If not existing or set in connection string.",CommandOptionType.SingleValue);
74
75
vartableNameArg=command.Argument("[tableName]","Name of the table to be created.");
command.Error=Error;//internal command Out/Erro are not yet changed, possible shortcomming
98
+
command.Error=Error;//internal command Out/Error are not yet changed, possible shortcoming
99
99
command.Out=Out;
100
100
101
101
command.Description="Generate creation script";
102
-
vardatabaseNameArg=command.Argument("[databaseName]","Name of the database.");
102
+
//var databaseNameArg = command.Argument("[databaseName]", "Name of the database.");
103
+
vardatabaseNameOpt=command.Option("-d|--databaseName","Name of the database. If not existing or set in connection string.",CommandOptionType.SingleValue);
103
104
vartableNameArg=command.Argument("[tableName]","Name of the table to be created.");
104
105
command.HelpOption("-?|-h|--help");
105
106
106
107
command.OnExecute(async()=>
107
108
{
108
-
if(string.IsNullOrEmpty(databaseNameArg.Value)
109
-
||string.IsNullOrEmpty(tableNameArg.Value))
109
+
if(string.IsNullOrEmpty(tableNameArg.Value))
110
110
{
111
111
awaitError.WriteLineAsync("Invalid input");
112
112
cliApp.ShowHelp(command.Name);
113
113
return2;
114
114
}
115
115
116
-
_databaseName=databaseNameArg.Value;
116
+
_databaseName=databaseNameOpt.Value();
117
117
_tableName=tableNameArg.Value;
118
118
119
119
returnawaitGenerateScript();
@@ -169,12 +169,6 @@ public int Run(string[] args)
169
169
awaitcommand.ExecuteNonQueryAsync(token);
170
170
}
171
171
172
-
//using (var command = new MySqlCommand(sqlQueries.CreateNonClusteredIndexOnExpirationTime,
173
-
// connection, transaction))
174
-
//{
175
-
// await command.ExecuteNonQueryAsync(token);
176
-
//}
177
-
178
172
transaction.Commit();
179
173
180
174
awaitOut.WriteLineAsync("Table and index were created successfully.");
0 commit comments