Created
March 10, 2021 22:34
-
-
Save basyusuf/3983eba1b8f8bd4db3da6859524e86bd to your computer and use it in GitHub Desktop.
Bad Singleton Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Redis { | |
private id: number; | |
private base_url: string; | |
private port: number; | |
constructor(base_url: string, port: number = 6379) { | |
this.base_url = base_url; | |
this.port = port; | |
this.id = new Date().getTime(); | |
} | |
connect() { | |
console.log(`${this.base_url}:${this.port}`); | |
console.log("Connected Redis, instance id:", this.id) | |
} | |
execQuery() { | |
console.log("Executed query!") | |
} | |
//Getter and setters.. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment