UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'KGlP1gNYvdztN2HutgKViICtksbDsAAM5sz1Rynq1R4='
WHERE
key_id = '50a27970cc2e687405ca88da6a0366ac9e80a8bbaf31439613618bb59f6a759b'
AND (
token = 'KGlP1gNYvdztN2HutgKViICtksbDsAAM5sz1Rynq1R4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)