UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'a9fRJE0wZVcfBQRekUOxeIImp1FCwTI71S5E9TvHFGc='
WHERE
key_id = '54c33d7574486d3e8e4fee834937fc9bcc4a990d5f00cd15a1669f0910ec20b6'
AND (
token = 'a9fRJE0wZVcfBQRekUOxeIImp1FCwTI71S5E9TvHFGc='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)