UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Y+uFfZee0QxbLsaJYYfQOSZ0mlEkn2W0CIxBcEKEj+0=' 
WHERE 
  key_id = '77374340da0868569c7d9af993d651f158a14f7bd43972909c9c59f253435c73' 
  AND (
    token = 'Y+uFfZee0QxbLsaJYYfQOSZ0mlEkn2W0CIxBcEKEj+0=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034