UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '0yy9Hn0dmH2IMqxOaZFiGr0j3wiTYhsREFF75mea0i4='
WHERE
key_id = 'bad02cbdcfa296ba4e85bf3fe61c5528386609901b68a2af0b279166728266ef'
AND (
token = '0yy9Hn0dmH2IMqxOaZFiGr0j3wiTYhsREFF75mea0i4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)