UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '9vFnWDNxO42oOacOD9oRaQ6hvOrHNFFA2UdpWdXgcSw='
WHERE
key_id = 'd59a0bc3cf31a4df4272d4e7b623053f881348d9648a86c188b5ce15190b250b'
AND (
token = '9vFnWDNxO42oOacOD9oRaQ6hvOrHNFFA2UdpWdXgcSw='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)