UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'T3CpkxVRgwviHDK7solsocUzKVRB47NvpD95sC9WpOw=' 
WHERE 
  key_id = '802c3b29905351de99acbadc65016c642baf772b46d7c547f8822a6a619044a1' 
  AND (
    token = 'T3CpkxVRgwviHDK7solsocUzKVRB47NvpD95sC9WpOw=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00037