Skip to content

Instantly share code, notes, and snippets.

@basyusuf
Created March 10, 2021 22:34
Show Gist options
  • Save basyusuf/3983eba1b8f8bd4db3da6859524e86bd to your computer and use it in GitHub Desktop.
Save basyusuf/3983eba1b8f8bd4db3da6859524e86bd to your computer and use it in GitHub Desktop.
Bad Singleton Example
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