github.com/projecteru2/core@v0.0.0-20240321043226-06bcc1c23f58/store/redis/lock.go (about)

     1  package redis
     2  
     3  import (
     4  	"fmt"
     5  	"time"
     6  
     7  	"github.com/projecteru2/core/lock"
     8  	redislock "github.com/projecteru2/core/lock/redis"
     9  )
    10  
    11  // CreateLock creates a redis based lock
    12  func (r *Rediaron) CreateLock(key string, ttl time.Duration) (lock.DistributedLock, error) {
    13  	lockKey := fmt.Sprintf("%s/%s", r.config.Redis.LockPrefix, key)
    14  	return redislock.New(r.cli, lockKey, ttl, ttl)
    15  }