I am trying to write a module that communicates with redis. So far its doing following things. 

1. Get the token
2. if token A then connect to redis A
3. else connect to redis B
4. get data for a specific key
5. delete a key

Here is what I have written:

```
import redis

def get_data(token):

    if token == "tokenA" 
        connection = redis.Redis(connection_pool=name_of_redis_engine1)
    else:   
        connection = redis.Redis(connection_pool=name_of_redis_engine2)

    data = connection.hgetall(token)
    if not data:
        raise Some Error

    return data

def delete_data(token):

    connection = redis.Redis(connection_pool=name_of_redis_engine)

    data = redis_connection.delete(token)
    if not data:
        raise Some Error

    return data

```

Since, there is a some duplicate data in both functions which is not a good approach. I was wondering about whats the best way to make it neat Maybe class? . Will appreciate any help alot.