UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'qX+ZROuoHV0aygBRREAuspDtLa3GXi+52u9bUOK6Ccs='
WHERE
key_id = 'd28d837f765f8bc08eae93a76c8b09d84621963b5e4f0594b697eff35aae45bd'
AND (
token = 'qX+ZROuoHV0aygBRREAuspDtLa3GXi+52u9bUOK6Ccs='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)