UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'XjSJyVYyNDUhxGN3bj7IoPyLE10i+apda7gf5upb6J8='
WHERE
key_id = 'cd359142a9ac6be6c4fa15086832a46d381b1a948a13da9755fa7020c258f351'
AND (
token = 'XjSJyVYyNDUhxGN3bj7IoPyLE10i+apda7gf5upb6J8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)