<?php

namespace tw\redis\traits;

use tw\redis\TwRedis;

trait KeyTrait
{
    public function keys(string $pattern): array
    {
        return TwRedis::keys($pattern);
    }

    public function expire($word, int $secs): bool
    {
        return TwRedis::expire($this->key($word), $secs);
    }

    /**
     * 设置超时时间戳，到达该时间戳后，key 失效
     */
    public function expire_at($word, int $ts): bool
    {
        return TwRedis::expireAt($this->key($word), $ts);
    }

    public function del($word): int
    {
        return TwRedis::del($this->key($word));
    }

    public function type($word)
    {
        return TwRedis::type($this->key($word));
    }

    public function exists($word): int
    {
        return TwRedis::exists($this->key($word));
    }
}
