UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'KEQi1JGgGJakUhXLL4RLrKSVwxh6WtS0u15x7BRX5+U='
WHERE
key_id = 'a52395464cbcbba254f259472911efe498f1cca5a714f50d17ee4e68736f0fd3'
AND (
token = 'KEQi1JGgGJakUhXLL4RLrKSVwxh6WtS0u15x7BRX5+U='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)