UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'gW1QRgU7TcRfQhNifKaHa5Af62OOY88ShaH2AyEJ7kk='
WHERE
key_id = '4781e220d7c0d8a36123add9795c2d4a2efe0fc8f1fa5e456a039c87b9b2e3df'
AND (
token = 'gW1QRgU7TcRfQhNifKaHa5Af62OOY88ShaH2AyEJ7kk='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)