The Konnect product leverages an internal facing administration portal we have built to aid KORE employees to manage the products client base. The KONNECT Admin Portal (KAP) currently provides the internal members the ability to create, update and read the products client list as well as customize the configurations for the individual client by turning on/off different setting toggles. We want to expand the functionality of the KAP to also help us manage the product's caches. Currently KONNECT has implemented a Redis cache on AWS that we use extensively across the application. At the moment, the dev team has no way to visualize and/or interact with the keys on the cache outside of custom console applications that we write on an as needed basis. We, the dev team, have been talking about building a portal that would allow us to interact withthe keys in a more efficient way than building/manipulating console applications
- An application for the internal team to interact with the Redis cache that has the following functionalities:
- Ability to read from a well-organized list / grid
- Paginated results
- Number of existing keys ranges between 1,000 < x < 1,000,000
- Search functionality with the ability to search the entire list of keys by pattern
- The dev team should be able to perform the following CRUD operations
- Create new key value pair
- Retrieve paginated key list
- Retrieve value of selected key
- Remove individual key
- Remove keys by pattern
- Remove keys by selection
- Configurable / dynamic filtering
- Redis key pattern generator
View API Documentation here
Installing Redis on Windows with Ubuntu
-
Download ubuntu from Microsoft Store
-
Run this following command lines on Ubuntu
$ sudo apt-get update
$ sudo apt-get upgrade
- Installing Redis on Ubuntu
$ sudo apt-get install redis-server
- Start Redis server on Ubuntu
$ redis-server
- To Test if Redis server is running
$ redis-cli ping
$ PONG << expected reply
Installing Redis on Mac with Brew
-
Download and Install Homebrew
-
Update and Install Redis on Brew
brew update
brew install redis
- To start Redis server
brew services start redis
- To stop Redis server
brew services stop redis
- To Test if Redis server is running
redis-cli ping
PONG << expected reply
How to SET and GET Redis key
Redis-cli SET "Key1" "Value1"
OK << expected reply
Redis-cli GET "Key1"
"Value1" << expected reply
- Microsoft Visual Studio
- .NET Core 3.1
- Ubuntu
- Redis
- NodeJS To get a local copy up and running follow these steps.
-
Clone the repo
git clone https://github.com/nkrachangtoy/kap-cache-management.git
-
Go to /server/KONNECT-REDIS
cd server/KONNECT-REDIS
-
Double click
KONNECT-REDIS.sln
to open the project -
Rename
appsettingsSAMPLE.json
andappsettingsSAMPLE.Development.json
toappsettings.json
andappsettings.Development.json
repectively -
Install Nuget Packages From within Visual Studio you can use the Package Manager Console to also update the packages. This has the benefit that any PowerShell scripts will be run as part of the update where as using NuGet.exe will not run them. The following command will update all packages in every project to the latest version available from nuget.org.
Update-Package
-
Inside
Startup.cs
(Optional) If you want to use the interactive API Documentation with Swagger, uncomment the following outlined code blocks://============================================================================= // UNCOMMENT THIS BLOCK DURING LOCAL DEV FOR DOCUMENTATION (SWAGGER CONFIG) //============================================================================= services.AddSwaggerGen(options => { options.SwaggerDoc("KonnectAPI", new Microsoft.OpenApi.Models.OpenApiInfo() { Title = "Konnect - Redis Cache - API", Version = "1", Description = "API Documentation by Konnect Dev Team" }); options.IncludeXmlComments("KONNECT-REDIS.xml"); }); //============================================================================= // UNCOMMENT THIS BLOCK DURING LOCAL DEV FOR DOCUMENTATION (SWAGGER CONFIG) //============================================================================= .... //============================================================================= // UNCOMMENT THIS BLOCK DURING LOCAL DEV FOR DOCUMENTATION (SWAGGER CONFIG) //============================================================================= app.UseSwagger(); app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/KonnectAPI/swagger.json", "Konnect - Redis Cache - API"); options.RoutePrefix = ""; }); //============================================================================= // UNCOMMENT THIS BLOCK DURING LOCAL DEV FOR DOCUMENTATION (SWAGGER CONFIG) //=============================================================================
-
To connect to local Redis server, open
Starup.cs
and add the following code:public void ConfigureServices(IServiceCollection services) { [...] // Configure Redis Connection var options = new ConfigurationOptions { EndPoints = { "localhost:<YOUR_REDIS_PORT>" }, }; services.AddSingleton<IConnectionMultiplexer>( ConnectionMultiplexer.Connect(options)); [...]
And change your Redis .GetServer() in
KeyService.cs
public KeysService(IConnectionMultiplexer multiplexer, IConfiguration configuration) { _multiplexer = multiplexer; Configuration = configuration; _db = _multiplexer.GetDatabase(); _server = _multiplexer.GetServer("localhost", <YOUR_REDIS_PORT>); _keys = _server.Keys(0, pattern: "*", pageSize: 100000); _regex = new Regex(@"^[0-9]+$"); }
-
Run the app by pressing
F5
- Microsoft.AspNetCore.Mvc.NewtonsoftJson V3.0.0
- StackExchange.Redis V2.2.4
- Swashbuckle.AspNetCore V6.1.3
- Within the client folder of the repo, run
npm install
to install packages - To start the app locally, run
npm start
- AgGrid
- Material-UI Core
- Material-UI Icons
- Axios
- CodeMirror
- Toastr
- React with Typescript
- The Delete function has two modes:
- If nothing is selected and the delete button is pressed, a query drawer will open and bulk delete can be done by Redis Query
- If there are selections, the selections will be deleted and the query drawer will not open
- Searching must be done by Redis query
- for example "IsFeature" will produce no results, but "IsFeature*" will result in all keys that start with "IsFeature".