UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'CA6nb/uvdix7coYCNopMuzIrNRyWyLCZVA6V4LzYyQ0='
WHERE
key_id = 'b13d959b7632e7c1da893d38bd79eec21e23ca8ee43e312cba33a595f97a7704'
AND (
token = 'CA6nb/uvdix7coYCNopMuzIrNRyWyLCZVA6V4LzYyQ0='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)