UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'aiX+OdS259FYIyoKWAHEipOexWuAUmDC7fhaxN+W1P0=' 
WHERE 
  key_id = '5773701cc287f1b8c4232804c04c8db29753caecada89e996201fc881bf5da42' 
  AND (
    token = 'aiX+OdS259FYIyoKWAHEipOexWuAUmDC7fhaxN+W1P0=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00031