UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '8RO9vdGs+B+TPNbwADEUCaVS4G3SZIZQYq7Ja7x0cdg='
WHERE
key_id = '397b61b15c5fc5e0903ecc7d2f1707918952c7ca17576802b2e58df64dfd6700'
AND (
token = '8RO9vdGs+B+TPNbwADEUCaVS4G3SZIZQYq7Ja7x0cdg='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)