Git Product home page Git Product logo

redisql's Introduction


Example Usage

CLI

Installation and Configuration:

go install github.com/DGKSK8LIFE/redisql/redisql

Create a YAML file with the following structure:

sqltype:
sqluser: 
sqlpassword: 
sqldatabase:
sqlhost:
sqlport:
sqltable:
redisaddr:
redispass:
log_level:
log_filenane:

(log_level and log_filename are optional. Default logging is none and default output is stdout)

Logging Levels:

  • 0 - no logging at all
  • 1 - summary of actions being performed by redisql
  • 2 - all actions (including individual keys and their values being performed by redisql

Usage:

# copy to redis string
redisql copy -type=string -config=pathtofile.yml 

# copy to redis list
redisql copy -type=list -config=pathtofile.yml

# copy to redis hash
redisql copy -type=hash -config=pathtofile.yml

Library

Installation:

go get github.com/DGKSK8LIFE/redisql

Usage:

package main

import (
    "github.com/DGKSK8LIFE/redisql"
)

func main() {
	config := redisql.Config{
		SQLType:     "mysql",
		SQLUser:     "root",
		SQLPassword: "password",
		SQLDatabase: "users",
		SQLHost:     "localhost",
		SQLPort:     "3306",
		SQLTable:    "user",
		RedisAddr:   "localhost:6379",
		RedisPass:   "",
	}
	err := config.CopyToString()
	if err != nil {
		panic(err)
	}
}

Other Methods:

// copy to redis list
config.CopyToList()

// copy to redis hash
config.CopyToHash()

Contributing

Check out CONTRIBUTING

Current Functionality and Limitations

  • Copying of entire SQL tables to Redis via CLI and Go Module
  • Support for most commonly used Redis data types (strings, lists, hashes)
  • Support for Postgres and MySQL
  • Advanced logging with levels and optional file output
  • Autosync
  • Dockerization

redisql's People

Contributors

cappe987 avatar dgksk8life avatar murilopereirame avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

redisql's Issues

Test Harness - MySQL Generate Table and Insert

  • Firstly, define users table
    • id (int & auto increment & Primary Key (PK))
    • name - not index
    • uuid (string) - index
    • height. ("5ft9" - string)
    • shoesize (number) must support Smol size - not a whole number (4.5)
    • age (integer)
    • bio (string)
    • friends_count (random between 3 - 75)
    • favourite_animal (string)
    • favourite_colour (string)
    • favourite_food (string)
    • mobile_phone (string)

Technical A/C

  • One of the tests need to be write 1,000,000 insert queries into MySQL.
  • Drop database completely before it does the test suite.

Summary
The purpose of this ticket is to prime an example MySQL db.

The intention is to write this inside the Go package so that eventually it can be in CI/CD.

Maybe use Faker for things like the favourite animal just to ensure that all sorts of string lengths and data is in the DB.

Outcomes

  • This could be recycled for other test suites, e.g. running 10,000 records with the replication later.
  • Ensure that the use of MySQL driver in the solution can handle this.
  • Pick a suitable testing framework (that automatically just profiles the amount of time it does).

[BUG] CopyToString is over 100% slower than other methods

Expected Behavior

Performance in CopyToString should be comparable to that of CopyToList and CopyToHash.

Current Behavior

CopyToString is over 100% slower than the aforementioned two.

Possible Solution

Because of Redis' data structures, CopyToString (strings) has to write one key per field, compared to CopyToList and CopyToHash that both write one key per row. This is not necessarily something that can be "quick fixed", but with other performance optimizations, especially transactions and pipelining, performance should improve drastically.

Steps to Reproduce

  1. Run test cases with ~10k rows or so and your preferred DB.
  2. View output:
โžœ  redisql git:(master) go test -v -db mysql -rows 10000 
Preparing Test...
=== RUN   TestCopyToString
--- PASS: TestCopyToString (8.43s)
=== RUN   TestCopyToList
--- PASS: TestCopyToList (0.75s)
=== RUN   TestCopyToHash
--- PASS: TestCopyToHash (0.92s)
PASS
ok      github.com/DGKSK8LIFE/redisql   17.995s

[FEATURE REQUEST] Add Docker support for redisql so that things like GitHub Actions can be used for CI/CD; and IDE setup is seamless.

Describe the solution you'd like

Provide a docker compose solution so a maintainer or user can run this box in isolation of needing PostgreSQL/MySQL and Redis to test this.

Describe alternatives you've considered

A docker image could be appropriate for testing which combines Go, MySQL, PostgreSQL and/or Redis in one box, however it would require maintenance of upstream Docker images and there's no performance penalty using docker compose, a docker-compose template allows maintainers to just completely retrash/rebuild their development environment by services.

Improve logs

Give better config options in terms of formatting, pretty-printing, log-file support, etc.

Change hash naming scheme

Currently hash names are generated with a UUID, but I want to preserve SQL table names, so I will use the Redis naming convention (object-type:id). Also want to give developers the option to override this.

2.0 Major Release

A new major release will fix all if not most current issues, optimize the library, introduce major refactors, etc overall.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.