UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '51166e954aaYI6ubo8z5SLSPbLxudpADHI0ExWCzuRE='
WHERE
key_id = '2981135ee4903bdef514d2431d88e7f42872aeaadea7b706dbeb57d43086931a'
AND (
token = '51166e954aaYI6ubo8z5SLSPbLxudpADHI0ExWCzuRE='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)